Difference between revisions of "toolpalette.register"

From Inspired-Lua Wiki
Jump to navigation Jump to search
Line 19: Line 19:
 
== Example  ==
 
== Example  ==
  
The script app uses this routine to register its tool palette with the Nspire framework. The menu structure is a table describing the name of each tool box, the menus that appear in each tool box, and the function to call when the user invokes the menu item.
+
The script app uses this routine to register its tool palette with the 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.
 
This example demonstrates the layout of a toolpalette’s menu structure.<br />
 
This example demonstrates the layout of a toolpalette’s menu structure.<br />
  
Line 40: Line 40:
 
     },
 
     },
 
}
 
}
 +
 
toolpalette.register(menu)</syntaxhighlight>
 
toolpalette.register(menu)</syntaxhighlight>
  

Revision as of 22:28, 24 May 2011

toolpalette.register is a function that is part of the toolpalette.

toolpalette.register may be called once in the top level flow of the script app. Once registered, the tool palette is managed automatically by the Nspire framework. When the user chooses an item from a toolbox, the associated function is called with two parameters: the name of the toolbox and the name of the menu item.

This has been introduced in TI-Nspire OS 3.0 (Changes).


Syntax

functionName(arg1, arg2, arg3 [,arg4])

Parameter Type Description
menuStructure (multi-level)-table Description of arg1

Example

The script app uses this routine to register its tool palette with the 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. This example demonstrates the layout of a toolpalette’s menu structure.

menu = {
  
    {“Mode”,                          -- Tool box “Mode”
       {“Decimal”, setDec},           -- Menu item “Decimal” calls function setDec()
       {“Hexadecimal”, setHex},
       {“Octal”, setOct},
       {“Binary”, setBin},
       “-“,                           -- Section divider
       {“Signed”, setSigned},
       {“Unsigned”, setUnsigned},
    },
    {“Boolean”,
       {“And”, binopAnd},
       {“Or”, binopOr},
       {“XOr”, binopXor},
       {“Not”, unopNot},
    },
}

toolpalette.register(menu)

See also