You are here: Lua Scripting Resources eGuide > Lua Scripting API Reference Guide > Tool Palette Library > register

17.1 register

toolpalette.register(menuStructure)

The script app uses this routine to register its tool palette with the TI-Nspire™ framework. The menu structure is a table describing the name of each toolbox, the menus that appear in each tool box, and the function to call when the user invokes the menu item.

The function toolpalette.register() can be called once in the top level flow of the script app. Once registered, the tool palette is managed automatically by the TI-Nspire™ framework. Up to 15 toolboxes can be created with up to 30 menu items each.

When the user chooses an item from a tool box, the associated function is called with two parameters: the name of the toolbox and the name of the menu item.

A call to toolpalette.register() within the paint context might be ignored and should therefore be avoided.

Beginning with apiLevel ‘2.0’ toolpalette.register() can be called multiple times in the program flow to change dynamically at runtime.
Calling toolpalette.register(nil) deactivates the toolpalette.

Listing 17.1 demonstrate the layout of a tool palette’s menu structure.

Introduced in platform.apiLevel = '1.0'

Extended in platform.apiLevel = ‘2.0’

Listing 17.1: Registering a Tool Palette

menu  = {
 {"Mode", -- Tool box "Mode"
  {"Decimal", setDec}, -- Menu item "Decimal" calls setDec()
  {"Hexadecimal", setHex},
  "-", -- Section divider
  {"Signed", setSigned},
  {"Unsigned", setUnsigned},
 },
 {"Boolean",
  {"And", binopAnd},
  {"Or", binopOr},
 },
} toolpalette.register(menu)