Nasal in GUI dialog files
|IMPORTANT: Some, and possibly most, of the features/ideas discussed here are likely to be affected, and possibly even deprecated, by the ongoing work on providing a property tree-based 2D drawing API accessible from Nasal using the new Canvas system available since FlightGear 2.80 (08/2012). Please see: Canvas for further information
You are advised not to start working on anything directly related to this without first discussing/coordinating your ideas with other FlightGear contributors using the FlightGear developers mailing list or the Canvas subforum . Anything related to Canvas Core Development should be discussed first of all with TheTom and Zakalawe. Nasal-space frameworks are being maintained by Philosopher and Hooray currently. talk page.
As of 10/2011 there is unfortunately no dedicated article available yet, but for the time being you can refer to $FG_ROOT/gui/dialogs, where you can find a number of GUI dialogs containing embedded Nasal code, you'll want to look for sections (tags) named nasal/open and nasal/close:
A bunch of helpers for creating scripted GUI dialogs can be found in $FG_ROOT/Nasal/gui.nas
Each dialog can have a <nasal> block with <open> and/or <close> element. Nasal code therein is executed on dialog opening and closing. This code and all Nasal code in the dialog bindings run in the same namespace, so one can initialize variables and functions in the <open> block and access them from everywhere in the file. The <close> block is for cleaning up (removing listeners, canceling timers, removing properties etc.)
This allows to write more sophisticated dialogs, and makes external dialog helper *.nas files unnecessary (e.g. the autopilot *.nas file). There's currently one dialog using this feature: location-in-air.xml, which handles the <radio>buttons with embedded Nasal.