166
edits
No edit summary |
No edit summary |
||
Line 7: | Line 7: | ||
Listeners - simple Nasal functions - can be attached to every element inside the Canvas and the Canvas itself. Once a certain action - like moving the mouse or pressing a button - occurs the associated listeners are called. We can use this for example to detect whether the mouse has moved over an element or if a certain element has been clicked. | Listeners - simple Nasal functions - can be attached to every element inside the Canvas and the Canvas itself. Once a certain action - like moving the mouse or pressing a button - occurs the associated listeners are called. We can use this for example to detect whether the mouse has moved over an element or if a certain element has been clicked. | ||
= Listen for events = | = Listen for events = | ||
Line 28: | Line 17: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
For each placement of a Canvas handling events can be enabled or disabled. A Canvas placed in a PUI widget or as standalone GUI window receives events by default, whereas Canvases placed onto the aircraft model or in the scenery do not receive any events by default. | For each placement of a Canvas handling events can be enabled or disabled. A Canvas placed in a PUI (old GUI) widget or as standalone GUI window receives events by default, whereas Canvases placed onto the aircraft model or in the scenery do not receive any events by default. | ||
{{Note|The old [[Howto:Adding_a_canvas_to_a_GUI_dialog|PUI/XML GUI]] does not trigger any mouseover/hover events. Mouse clicks/wheel/drag are working as expected. For all other placements like on standalone Canvas windows and [[Howto:Add_a_2D_canvas_instrument_to_your_aircraft|3D models]] there is no such limitation.}} | |||
For standalone GUI windows setting '''capture-events''' to ''0'' or ''1'' enables or disables handling of events respectively. For a Canvas placed onto a 3d model, setting ''capture-events'' inside the placement can be used to activate event handling: | For standalone GUI windows setting '''capture-events''' to ''0'' or ''1'' enables or disables handling of events respectively. For a Canvas placed onto a 3d model, setting ''capture-events'' inside the placement can be used to activate event handling: |
edits