Toggle Button Component
Insert a toggle button in a Standard Maple worksheet or document.
Component Palette Image
Toggle Button Properties
Toggle Button Component Example
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.
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.
true or false
name or string
The caption that appears on the button.
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.
The name of the component group.
The image that appears on the button when it is in the out state (the default state).
The image that appears on the button when it is in the on state.
The height of the image in pixels.
The width of the image in pixels.
Specifies if the border of the button is shown. By default, the value is true.
The text that appears when the user hovers the mouse over the button.
The type of the component. This returns "ToggleButton".
Whether the specified size of the image is used. By default, the value is false.
Specifies if the toggle button is selected. By default, the value is false.
Specifies if the button is visible. By default, the value is true.
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:
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.
Click the Text Area component to display the context panel.
Change the value for the Visible Character Width to 15.
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:
Click the Toggle Button component, and then select Edit Click Code.
This launches the Code Editor dialog.
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).
or from the File menu, select Save Code to accept all changes.
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.
Download Help Document
What kind of issue would you like to report? (Optional)