Toggle Button Component - Maple Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : Programming : Document Tools : Embedded Components : ToggleButtonComponent

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, right-click (Control-click for Macintosh) the toggle button, and then select Edit Click Action 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 ToggleButton Properties. To open the ToggleButton Properties, right-click (Control-click for Macintosh) the toggle button, and then select Component Properties. 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 G column indicates that the option can be read, that is, retrieved by using the DocumentTools[GetProperty] tool.

  

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

Option           G  S  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           
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.

  

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. 

Right-click (Control-click for Macintosh) the Text Area component, and then select Component Properties.

3. 

Change the value for the Visible Character Width to 15.

4. 

Change the value for the Visible Rows to 2.

5. 

Click OK to accept all settings.

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

1. 

Right-click (Control-click for Macintosh) the Toggle Button component, and then select Edit Click Action.

This launches the Code Editor dialog with preset statements and additional information on how to program actions between embedded components.

2. 

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

Do( %Plot0 = plot( %TextArea0, x=0..10, filled=%ToggleButton0));

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

3. 

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.

  

 

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

DocumentTools[Do](%Plot0 = plot(%TextArea0, x=0..10, filled = %ToggleButton0));

See Also

ButtonComponent

CheckBoxComponent

ComboBoxComponent

DataTableComponent

DialComponent

DocumentTools

DocumentTools[Do]

DocumentTools[GetProperty]

DocumentTools[SetProperty]

EmbeddedComponents

LabelComponent

ListBoxComponent

Maplets[Elements][Button]

MathExpressionComponent

MeterComponent

PlotComponent

RadioButtonComponent

RotaryGaugeComponent

SliderComponent

TextAreaComponent

VideoPlayerComponent

VolumeGaugeComponent

 


Download Help Document

Was this information helpful?



Please add your Comment (Optional)
E-mail Address (Optional)
What is ? This question helps us to combat spam