We don't have any good solution for the concept of "optional expiration" - despite having listeners, timers and even simulation time. So I had to use a combination of those.
On the C++/osgGA side, the mouse-dragging code could contain some hints ?
We could probably make it a separate event type, analogous to how clicks and button down/up events are tracked separately, for instance we could provide support for optional "timeout" parameters that are invoked if the mouse down event is held for a certain duration, so that the corresponding Nasal callback gets invoked that way, so that you can pass the usual data structure ?
- Code: Select all
canvas_element.addEventListener(event:"mousedown", callback:foo, expire_after:3.0, expiry_callback:bar );
or really a new event type for "button held" + duration:
- Code: Select all
canvas_element.addEventListener(event:"buttonheld", duration:3.0, callback:myCallback );
canvas_element.addEventListener(event:"click", callback:clickhandler );
that should not collide - internally, the "buttonheld" event would be a "mousedown" event that triggers an expiring timer (event_mgr) or registers a callbacks that check "duration" seconds later if the button is still held.
Separate events looks cleaner to me - but the problem is, we'll still need Nasal workarounds, because even if Canvas would support this, the <mod-up> stuff would also need updating, too