``` Button b2 = new Button(); b2.Click += new Rou...
# announcements
p
Copy code
Button b2 = new Button();
b2.Click  += new RoutedEventHandler(Onb2Click);
g
yeah, I actually like the += syntax a fair bit, since I think its pretty concise. What I want is for
Copy code
Button b2 = new Button();
b2.Click  += new RoutedEventHandler(Onb2Click);

b2.Click(ClickEvent()); //or b2.Click.fire(ClickEvent()) or whatever your syntax is
to be a compiler failure.
@bj0 out of curiosity what is your favourite event syntax?
b
i don't mind the
+=
syntax, though it's not clear as just calling a function. I really don't like having to wrap functions in handler objects though. Luckily you don't actually have to do that
g
This looks more clear for me. Button().click.addListener { /* your code */ } or Button().click.setListener { /* your code */ } Because you should somehow separate between cases when your API supports only one listener or any amount of listeners.
n
Geoff - Would have changed the property name to reflect that multiple event handlers can be stored, eg b2.clickHandlers.
Using addListener and removeListener functions is the cumbersome Java way to manage event handlers, which adds unnecessary boilerplate. The Kotlinic way to manage event handlers is more readable/easier to follow.