MacGapProject / MacGap1

Desktop WebKit wrapper for HTML/CSS/JS applications.
Other
3.55k stars 208 forks source link

Allow Obj-C to trigger JavaScript events containing additional key-value data #97

Closed jeff-h closed 10 years ago

jeff-h commented 10 years ago

This adds the ability for the MacGap triggerEvent method to trigger an event on the JavaScript side, which contains a data object.

This is useful in numerous cases, and extends the triggerEvent method in a small but useful way.

For example, if the NSWorkspace detects a NSWorkspaceDidActivateApplicationNotification, it's helpful to pass information about the activated application back to the JavaScript event handler.

Javascript:

document.addEventListener('didActivateApplication', function(e){
    console.log(e.data);
}, true);