v0.100.0 "ev"
Here come the "ev" system for (real) events mechanism.
I didn't planned to introduce such a big change like this, but it will be a lot better !
Til now ... the "object" (caller_object) which is passed to the callback method is the current object which has emitted the event.
def add_content( caller_object ): # caller_object is the Tag.button
self += "hello"
self += Tag.button("add", _onclick=add_content)
Now, there is a quirk, to pass a "real event" (like a javascript dom event) : if you name it "ev", htag will pass an "event" ! So you will need to adapt your code to :
def add_content( ev ): # ev is a event (namedTuple)
self += "hello"
self += Tag.button("add", _onclick=add_content)
And now, ev is not a "caller object" anymore, but an "event" ... and so, the "caller object" is in ev.target
(like in js side), others properties are properties of ev (ex: ev.clientX
)
It's a quirk (because it's only based on the name of the argument), but I have a lot of components to adapt ... and don't want to introduce big api changes too. But need to find a better way for the future 1.0 ;-)
IMPORTANT : this version works only on simple callback (with a unique parameter "ev"). If you try to bind "ev" and other parameters : it can't work ! Need to fix soon