Nasal in GUI dialog files

From FlightGear wiki
Jump to navigation Jump to search
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 This is a link to the FlightGear forum.. 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:

  • about.xml
  • airports.xml
  • autopilot.xml
  • chat-menu.xml
  • file-select.xml
  • formation.xml
  • gps.xml
  • hud.xml
  • jetways-adjust.xml
  • jetways.xml
  • joystick-info.xml
  • location-in-air.xml
  • location-on-ground.xml
  • lso-view.xml
  • map.xml
  • marker-adjust.xml
  • message.xml
  • model-cockpit-view.xml
  • model-view-select.xml
  • model-view.xml
  • multiplayer.xml
  • nasal-console.xml
  • NTPS_target_task.xml
  • property-browser.xml
  • pushback.xml
  • random-failures.xml
  • rendering.xml
  • replay.xml
  • route-manager.xml
  • scenario.xml
  • seaport.xml
  • sound.xml
  • stopwatch.xml
  • system-failures.xml
  • terrasync.xml
  • tutorial.xml
  • view.xml
  • weather.xml

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.

read more here: