Board index FlightGear Development Canvas

addEventListener() & tooltips.nas

Canvas is FlightGear's new fully scriptable 2D drawing system that will allow you to easily create new instruments, HUDs and even GUI dialogs and custom GUI widgets, without having to write C++ code and without having to rebuild FlightGear.

addEventListener() & tooltips.nas

Postby Hooray » Fri Feb 14, 2014 8:53 pm

I am using .addEventListener() on a canvas element to receive mouse events inside a PUI CanvasWidget and trigger a callback, which is working fine when using 'click', but no longer works when using 'mouseover' apparently.
Basically, I want to register custom tooltip windows to be optionally shown when hovering over a corresponding symbol on the map - clicking seems to work, but triggers a bunch of events per click apparently, also when using a whole canvas dialog/window, I need to manually manage closing it.

This is primarily about adding LOD-handling to MapStructure-based GUI dialogs, i.e. I was going to show a more detailed LOD of an element when hovering over an element, such as an airport, navaid or AI/MP aircraft - which is why I'd prefer being able to use "mouseover" and the existing tooltip class. Any ideas appreciated.

I only played with this for a few minutes, but it seems I must be missing something ...
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Posts: 11965
Joined: Tue Mar 25, 2008 8:40 am

Re: addEventListener() & tooltips.nas

Postby adrian » Fri Feb 14, 2014 9:03 pm

I'm not familiar with the platform, but basically you'd want to extend the parent class and override onHoverEnter event and onHoverLeave event. If it's similar to what I know, it should be enough to call accept on events and show/destroy your own tooltip on enter/leave. Of course, it could be completely different in Nasal.
Posts: 362
Joined: Wed Sep 15, 2010 2:15 pm

Return to Canvas

Who is online

Users browsing this forum: No registered users and 1 guest