Table of Contents

Creating customized menus

The menu engine in newRPL retains the basic concepts of the one used in userRPL but provides new features such as help messages and dynamic menu appearance.

The most important command used to display a custom menu is TMENU which displays the menu on the active menu area. It accepts either an integer or a list: the former is used to display a preset system menu but here we will discuss about the latter, which allows to display a fully customized menu.

The menu structure

The menu is structured as a list of items, where each item defines a softkey:

{
  Item_1
  ...
  Item_n
}

If more than 6 items exist, the menu will be split in pages of 5 softkeys each, and the rightmost softkey of each page will turn into a NXT… key to display a new page; as usual, pressing any shift and NXT… will display the previous page.

Each item can be a single object or a three elements list: in the first case the offect depends on the type of the object:

In the second case, each element of the list takes care of an aspect of the softkey:

{
  <Display>
  <Action>
  <Help>
}

The DISPLAY object

The <Display> object can be either a single object or a two elements list; if it is a single object:

If <Display> object is a two elements list:

{
  <Display>
  <Decoration>
}

the <Display> part works exactly as above while the <Decoration> part is an integer interpreted as a binary number:


The ACTION object

The <Action> object is optional and can be either a single object, a three or a five elements list; if it is a single object:

and all these actions will happen whether the softkey is pressed unshifted, shifted or hold-shifted.

If the <Action> object is a three elements list:

{
  <Normal_Action>
  <Left-Shift_Action>
  <Right-Shift_Action>
}

the user can define three separate actions for unshifted and shifted softkeys.

If the <Action> object is a five elements list:

{
  <Normal_Action>
  <Left-Shift_Action>
  <Right-Shift_Action>
  <Left-Shift-Hold_Action>
  <Right-Shift-Hold_Action>
}

the user can define five separate actions for unshifted, shifted and hold-shifted softkeys.


The HELP object

The <Help> object is an optional string that will be displayed in the help area when the softkey is long-pressed; a line break can be inserted using the RS-DOT key combination in Alpha mode.


newRPL has two menu areas available to the user which can be exploited to create a multilevel menu structure. Since newRPL allows the user to choose either MENU 1 or MENU 2 as active area, it is more convenient to refer to the two menus not in absolute terms but in chronological terms; in other words, three commands are available to display a custom menu:

In this way an application can easily create a multilevel menu hierarchy and have both levels displayed on the screen at once. Of course, such a structure must be traversed also backwards, therefore three suitable commands are provided:

Finally, to retrieve on the stack the definitions of the custom menus the following commands are provided:


Example: a 3-levels menu template

The following programs build a 3-levels menu: the resulting program is just an empty shell, but demonstrates effectively the following techniques:


Program L1The top level menu

{ 
  { { "File" 1 } :: L2 TMENULST ; "File operations" }
  { { "Edit" 0 } :: ; "Edit file" }
  { { "Search" 0 } :: ; "Search text" }
  { "" }
  { "" }
  { { "Quit" 0 } :: #00040000h TMENUOTHR #04402000h TMENU ; "Quit application" }
}

—-

Program L2The second level menu

{ 
  { { "New" 0 } :: ; "Create new file" }
  { { "Open" 0 } :: ; "Open existing file" }
  { { "Save" 1 } :: L3 TMENUOTHR ; "Save file" }
  { "" }
  { "" }
  { "Back" :: { } TMENUOTHR MENUBKLST ; "Back to Main menu" }
}

Program L3The third level menu

{ 
  { "Save" :: ; "Save file" }
  { "As..." :: ; "Save with another name" }
  { "Copy" :: ; "Save a duplicate" }
  { "" }
  { "" }
  { "Back" :: { } TMENULST MENUBKOTHR ; "Back to Main menu" }
}

Program MAINPutting everything together

«
  { } TMENULST
  { } TMENUOTHR
  L1 TMENU 
»