Skip to end of metadata
Go to start of metadata

void FB::JSAPIAuto::FireJSEvent ( const std::string &  eventName,
const FB::VariantMap members,
const FB::VariantList arguments 
) [virtual]

Fires an event into javascript asynchronously using a W3C-compliant event parameter.

This fires an event to all handlers attached to the given event in javascript. With a W3C-compliant event parameter

IE:

      document.getElementByID("plugin").attachEvent("onload", function() { alert("loaded!"); });

Firefox/Safari/Chrome/Opera:

      // Note that the convention used by these browsers is that "on" is implied
      document.getElementByID("plugin").addEventListener("load", function() { alert("loaded!"); }, false);;/.

You can then fire the event -- from any thread -- from the JSAPI object like so:

      FireEvent("onload", FB::variant_list_of("param1")(2)(3.0));

Also note that registerEvent must be called from the constructor to register the event.

      registerEvent("onload");
Parameters:
eventName Name of the event. This event must start with "on"
members 
arguments The arguments that should be sent to each attached event handler
See also:
registerEvent

Reimplemented from FB::JSAPIImpl.

Definition at line 424 of file JSAPIAuto.cpp.

References FB::variant::cast(), getAttribute(), and FB::variant::is_of_type().

00425 {
00426     JSAPIImpl::FireJSEvent(eventName, members, arguments);
00427     FB::variant evt(getAttribute(eventName));
00428     if (evt.is_of_type<FB::JSObjectPtr>()) {
00429         VariantList args;
00430         args.push_back(FB::CreateEvent(shared_from_this(), eventName, members, arguments));
00431         try {
00432             evt.cast<JSObjectPtr>()->InvokeAsync("", args);
00433         } catch (...) {
00434             // Apparently either this isn't really an event handler or something failed.
00435         }
00436     }
00437 }

Here is the call graph for this function:


Generated on 25 May 2013 for FireBreath by  doxygen 1.6.1
Labels
  • None