1
0
Fork 0

CanvasEvent: expose event target to Nasal

This commit is contained in:
Thomas Geymayer 2012-12-16 21:32:05 +01:00
parent 32e959e88a
commit cef12d406c

View file

@ -162,6 +162,11 @@ naRef f_groupGetElementById(sc::Group& group, const nasal::CallContext& ctx)
); );
} }
naRef f_eventGetTarget(naContext c, sc::Event& event)
{
return NasalElement::create(c, event.getTarget().lock());
}
// TODO allow directly exposing functions without parameters and return type // TODO allow directly exposing functions without parameters and return type
naRef f_eventStopPropagation(sc::Event& event, const nasal::CallContext& ctx) naRef f_eventStopPropagation(sc::Event& event, const nasal::CallContext& ctx)
{ {
@ -175,6 +180,7 @@ naRef initNasalCanvas(naRef globals, naContext c, naRef gcSave)
{ {
NasalEvent::init("canvas.Event") NasalEvent::init("canvas.Event")
.member("type", &sc::Event::getTypeString) .member("type", &sc::Event::getTypeString)
.member("target", &f_eventGetTarget)
.method_func<&f_eventStopPropagation>("stopPropagation"); .method_func<&f_eventStopPropagation>("stopPropagation");
NasalMouseEvent::init("canvas.MouseEvent") NasalMouseEvent::init("canvas.MouseEvent")
.bases<NasalEvent>() .bases<NasalEvent>()