Changes

Jump to navigation Jump to search

toolpalette.register

78 bytes removed, 12:20, 21 December 2011
Line 1: Line 1:  
toolpalette.'''register''' is a function that is part of the [[:Category:toolpalette| toolpalette]].
 
toolpalette.'''register''' is a function that is part of the [[:Category:toolpalette| 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.
+
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.<br />
 
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.
 
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.
   Line 7: Line 7:     
== Syntax  ==
 
== Syntax  ==
'''functionName'''(arg1, arg2, arg3 [,arg4])  
+
toolPalette.'''register'''(menuStructure)  
    
{| class="wikitable"
 
{| class="wikitable"
Line 13: Line 13:  
! Parameter !! Type !! Description
 
! Parameter !! Type !! Description
 
|-
 
|-
| <u>menuStructure</u> || (multi-level)-table || Description of arg1
+
| <u><center>menuStructure</center></u> || (multi-level)-table || 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
|-
+
   
 
|}
 
|}
    
== 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 toolbox, 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.  
This example demonstrates the layout of a toolpalette’s menu structure.<br />
+
 
 +
<syntaxhighlight>
 +
 
 +
function setDec()
 +
  ...
 +
end
 +
 
 +
-- All your functions defined in the menu --
   −
<syntaxhighlight>menu = {
+
menu = {
 
+
     {“Mode”,                          -- Tool box “Mode”
+
     {"Analysis",                          -- Tool box "Mode"
       {“Decimal”, setDec},          -- Menu item “Decimal” calls function setDec()
+
       {"Decimal", setDec},          -- Menu item "Decimal" calls function setDec()
       {“Hexadecimal”, setHex},
+
       {"Hexadecimal", setHex},
       {“Octal”, setOct},
+
       {"Octal", setOct},
       {“Binary”, setBin},
+
       {"Binary", setBin},
       -,                          -- Section divider
+
       "-",                          -- Section divider
       {“Signed”, setSigned},
+
       {"Signed", setSigned},
       {“Unsigned”, setUnsigned},
+
       {"Unsigned", setUnsigned},
    },
  −
    {“Boolean”,
  −
      {“And”, binopAnd},
  −
      {“Or”, binopOr},
  −
      {“XOr”, binopXor},
  −
      {“Not”, unopNot},
   
     },
 
     },
 +
    {"Boolean",
 +
      {"And", binopAnd},
 +
      {"Or", binopOr},
 +
      {"XOr", binopXor},
 +
      {"Not", unopNot},
 +
    }
 +
 
}
 
}
 
+
 
toolpalette.register(menu)</syntaxhighlight>
 
toolpalette.register(menu)</syntaxhighlight>
    
== See also  ==
 
== See also  ==
*[[:Category:toolPalette|toolPalette]]
+
*[[:Category:toolpalette|toolpalette]]
 
*[[toolpalette.enable]]
 
*[[toolpalette.enable]]
    
<br /><br />
 
<br /><br />
   −
[[Category:toolPalette]]
+
[[Category:toolpalette]]

Navigation menu