Toggle Button Component - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

Online Help

All Products    Maple    MapleSim


Toggle Button Component

Insert a toggle button in a Standard Maple worksheet or document.

 

Description

Component Palette Image

Toggle Button Properties

Toggle Button Component Example

Description

• 

The toggle button component alternates between the in (true) and out (false) states and performs an action or a series of actions accordingly, although assigning an action to a component is not required.

• 

To perform an action when a toggle button is clicked, click the toggle button to view the options in the context panel, and then select Edit Click Code to open the Code Editor dialog for the toggle button. Enter the commands you want to perform in the Code Editor dialog.

• 

You need to specify one or more embedded components that will display the output of the toggle button click. For more information, see the Toggle Button Component Example on this page.

• 

The toggle button component is customized by setting options in the Toggle Button context panel. To view the ToggleButton context panel, select the toggle button. Actions are associated with components using routines in the DocumentTools package.

• 

The Name property is used to reference the toggle button when using the routines from the DocumentTools package.

• 

The Group Name property is used to automatically group components of the same name. When a component is grouped, it acts as a radio button where all components of the same group name will automatically be de-selected when one is selected. Only the Maple code attached to the selected component of the group will be executed. The following components can be added to a group: Check Box Component, and Radio Button Component.

Component Palette Image

Toggle Button Properties

• 

The following table describes the control and use of the toggle button component options.

  

An x in the Get column indicates that the option can be read, that is, retrieved by using the DocumentTools[GetProperty] tool.

  

An x in the Set column indicates that the option can be written, that is, set by using the DocumentTools[SetProperty] tool.

  

 

Option

Get

Set

Option Type

caption

x

x

string

enabled

x

x

true or false

groupname

x

x

string

image

 

x

name or string

imageselected

 

x

name or string

pixelheight

x

x

positive integer

pixelwidth

x

x

positive integer

showborders

x

x

true or false

tooltip

x

x

string

type

x

 

string

usespecifiedsize

x

x

true or false

value

x

x

true or false

visible

x

x

true or false

  

 

  

caption 

  

The caption that appears on the button.

  

enabled 

  

Whether a button can be clicked. If enabled is set to false, the button is grayed out and any action associated with it cannot be initiated. By default, the value is true.

  

groupname 

  

The name of the component group.

  

image 

  

The image that appears on the button when it is in the out state (the default state).

  

imageselected 

  

The image that appears on the button when it is in the on state.

  

pixelheight 

  

The height of the image in pixels.

  

pixelwidth 

  

The width of the image in pixels.

  

showborders 

  

Specifies if the border of the button is shown. By default, the value is true.

  

tooltip 

  

The text that appears when the user hovers the mouse over the button.

  

type 

  

The type of the component. This returns "ToggleButton".

  

usespecifiedsize 

  

Whether the specified size of the image is used. By default, the value is false.

  

value 

  

Specifies if the toggle button is selected. By default, the value is false.

  

visible 

  

Specifies if the button is visible. By default, the value is true.

Toggle Button Component Example

Note: To interact with the examples provided below, open this help page as a worksheet and then execute the worksheet.

This example uses Plot, Text Area, and Toggle Button embedded components to plot the expression entered in the Text Area. Clicking on the Toggle Button plots the expression and changes the regions between the curve and x-axis from filled to unfilled.

To insert the components and configure the Text Area:

1. 

Insert a Plot, Text Area, and Toggle Button component using the Components palette. For information on displaying the Maple palettes, see the Show Palettes help page.

2. 

Click the Text Area component to display the context panel.

3. 

Change the value for the Visible Character Width to 15.

4. 

Change the value for the Visible Rows to 2.

 

To plot the expression in the Text Area and fill/unfill the regions under the curve when the Toggle Button is clicked:

1. 

Click the Toggle Button component, and then select Edit Click Code.

This launches the Code Editor dialog.

2. 

Before the end use; statement in the dialog, enter the following command:

SetProperty("Plot0", value, plot(parse(GetProperty("TextArea0", value)), x=0..10, filled=parse(GetProperty("ToggleButton0", value))));

Note: Ensure the names of the components are correct (that is, that they match the Name fields for their components).

3. 

Click  or from the File menu, select Save Code to accept all changes.

4. 

From the File menu, select Close Code Editor.

Enter a function inside the Text Area component, and then click the toggle button. A plot appears inside the Plot component. Toggling the button on and off changes the regions between the graph and the x-axis from filled to unfilled.

  

 

with(DocumentTools):

You can verify the syntax of the embedded component action by executing the command in the worksheet.

SetProperty("Plot0", value, plot(parse(GetProperty("TextArea0", value)), x=0..10, filled=parse(GetProperty("ToggleButton0", value))));

 

See Also

DocumentTools

DocumentTools[GetProperty]

DocumentTools[SetProperty]

EmbeddedComponents

Maplets[Elements][ToggleButton]