[webkit-dev] how do you do callbacks out of webkit into c++, objC or other bindings - e.g. "onclick" ?
darin at apple.com
Sat Aug 30 19:00:20 PDT 2008
On Aug 30, 2008, at 5:35 PM, Luke Kenneth Casson Leighton wrote:
> heck do i get a callback, into c++, objc or any other binding, from
> an "onclick"?
> so, for example, i could set an element's "onclick" method to call
> i've already set up an EventListener (using addWindowEventListener)
> but that's far from ideal, although it does take in eeeverything,
> which is required in a lot of instances in pyjamas, to handle e.g.
> mouse-move events, and to handle "event preview", thus allowing
> opportunities to stop event propagation...
> .. all that's taken care of.
> what _isn't_ taken care of is overriding window "onresize", element
> window "onbeforeclose", window "close", element "onblur" and all the
You can add event listeners for any event and any event target. The
name of the function to add an event listener is addEventListener. To
identify the event you want to listen to, you pass the event name.
Events have names like "resize", "click", "beforeclose", "blur", etc.
added as event listeners. For each attribute, such as "onclick",
there's a corresponding event, such as "click". The object can have
any number of event listeners listening to that particular event in
addition to the single one that will be created if there's an
For example, if you have a button element in Objective-C in a variable
named button, you can add a listener for clicks like this:
[button addEventListener:@click" listener:clickListener
The clickListener object must be a class that implements the
DOMEventListener protocol. When someone clicks the button, the
handleEvent: method of the clickListener will be called.
More information about the webkit-dev