Maplets[Elements] - Maple Programming Help

Home : Support : Online Help : Programming : Maplets : Elements : Window Body Elements : Maplets/Elements/ToggleButton

Maplets[Elements]

 ToggleButton
 define a toggle button

 Calling Sequence ToggleButton(opts)

Parameters

 opts - equation(s) of the form option=value where option is one of background, caption, enabled, font, foreground, group, image, onchange, reference, tooltip, value, or visible; specify options for the ToggleButton element

Description

 • The ToggleButton window body element defines a toggle button in a Maplet application.

 • The ToggleButton element features can be modified by using options.  To simplify specifying options in the Maplets package, certain options and contents can be set without using an equation. The following table lists elements, symbols, and types (in the left column) and the corresponding option or content (in the right column) to which inputs of this type are, by default, assigned.

 Elements, Symbols, or Types Assumed Option or Content Font element font option string or symbol caption option true or false value option

 • A ToggleButton element can contain Action or command elements to specify the onchange option, a Font element to specify the font option, and an Image element to specify the image option.
 • A ToggleButton element can be contained in a Maplet or BoxLayout element, or Maplet element in a nested list representing a box layout.
 • The following table describes the control and use of the ToggleButton element options.
 An x in the I column indicates that the option can be initialized, that is, specified in the calling sequence (element definition).
 An x in the R column indicates that the option is required in the calling sequence.
 An x in the G column indicates that the option can be read, that is, retrieved by using the Get tool.
 An x in the S column indicates that the option can be written, that is, set by using the SetOption element or the Set tool.

 Option I R G S background x x x caption x x x enabled x x x font x x x foreground x x x image x x group x onchange x tooltip x x x reference x value x x x visible x x x

 • The opts argument can contain one or more of the following equations that set Maplet application options.
 background = color
 The background color of the toggle button when it is off. (When it is on, the background color is always dark gray.) This can be a recognized color name, an RGB color structure, or a string of the form "#RRGGBB" where each pair is a two-digit hexadecimal number.
 caption = string or symbol
 The caption that appears on the toggle button.  The caption can have a mnemonic key or access key associated with it.  For more information, see Maplets Mnemonic Key.
 enabled = true or false
 Whether a toggle button can be clicked.  If enabled is set to false, the toggle button is dimmed, and any action associated with it cannot be initiated.  By default, the value is true.
 font = Font element or reference to a Font element (name or string)
 The text font on the toggle button.
 foreground = color
 The color of the text in the toggle button.
 group = reference to a ButtonGroup element (name or string)
 When this option is present, the behavior of the ToggleButton is modified to be similar to that of a RadioButton: only one button in the group can be selected. When this option is not present, the button can be toggled independently.
 image = Image element or reference to an Image element (name or string)
 An image displayed on the toggle button.
 onchange = Action or command element, or reference to an Action element (name or string)
 The action that occurs when the toggle button is changed.
 reference = name or string
 A reference to the ToggleButton element.
 tooltip = string or symbol
 The text that appears in the tooltip window.
 value = true or false
 The toggle button value.  By default, the value is false.
 visible = true or false
 Whether the toggle button is visible to the user.  By default, the value is true.

Examples

A Maplet application that displays two independent toggle buttons. On closing, it returns the state of the toggle buttons.

 > $\mathrm{with}\left(\mathrm{Maplets}\left[\mathrm{Elements}\right]\right):$
 > $\mathrm{maplet1}≔\mathrm{Maplet}\left(\left[\left[\mathrm{ToggleButton}\left['\mathrm{TB1}'\right]\left("This is a toggle button",'\mathrm{value}'=\mathrm{true}\right)\right],\left[\mathrm{ToggleButton}\left['\mathrm{TB2}'\right]\left("This is an independent toggle button",'\mathrm{value}'=\mathrm{false}\right)\right],\left[\mathrm{Button}\left("OK",\mathrm{Shutdown}\left(\left['\mathrm{TB1}','\mathrm{TB2}'\right]\right)\right),\mathrm{Button}\left("Cancel",\mathrm{Shutdown}\left(\right)\right)\right]\right]\right):$
 > $\mathrm{Maplets}\left[\mathrm{Display}\right]\left(\mathrm{maplet1}\right)$

A Maplet application that displays two grouped toggle buttons.  The user can select one. On closing, it returns the state of the toggle buttons.

 > $\mathrm{with}\left(\mathrm{Maplets}\left[\mathrm{Elements}\right]\right):$
 > $\mathrm{maplet2}≔\mathrm{Maplet}\left(\left[\left[\mathrm{ToggleButton}\left['\mathrm{TB1}'\right]\left("This is a toggle button",'\mathrm{value}'=\mathrm{true},'\mathrm{group}'='\mathrm{BG1}'\right)\right],\left[\mathrm{ToggleButton}\left['\mathrm{TB2}'\right]\left("This is another toggle button in the same group",'\mathrm{value}'=\mathrm{false},'\mathrm{group}'='\mathrm{BG1}'\right)\right],\left[\mathrm{Button}\left("OK",\mathrm{Shutdown}\left(\left['\mathrm{TB1}','\mathrm{TB2}'\right]\right)\right),\mathrm{Button}\left("Cancel",\mathrm{Shutdown}\left(\right)\right)\right]\right],\mathrm{ButtonGroup}\left['\mathrm{BG1}'\right]\left(\right)\right):$
 > $\mathrm{Maplets}\left[\mathrm{Display}\right]\left(\mathrm{maplet2}\right)$