Button Component - Maple Help

Online Help

All Products    Maple    MapleSim


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

Button Component

• 

The button component defines a button in a Standard Maple worksheet or document. This component performs an action or a series of actions to communicate with other embedded components when the button is selected, although assigning an action to a component is not required. The button component can display a caption or an image.  

• 

To perform an action when a button is clicked, right-click (Control-click for Macintosh) the button, and then select Edit Click Action to open the Code Editor dialog for the 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 button click. For more information, see the Button Component Examples on this page.

• 

The button component is customized by setting options in the Button Properties. To open the Button Properties, right-click (Control-click for Macintosh) the 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 button when using the routines from the DocumentTools package.

Component Palette Image

Button Properties

• 

The following table describes the control and use of the 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    
image               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    
visible          x  x  true or false    
                                         

  

caption 

  

The caption that appears on the button.  By default, the value is 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.

  

image 

  

The image that appears on the button. If both an image and a caption are specified, the image takes precedence.

  

pixelHeight 

  

The height of the image in pixels.

  

pixelWidth 

  

The width of the image in pixels.

  

showBorders 

  

Indicates 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.

  

visible 

  

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

Button Component Examples

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

Example 1 - Display a plot of sin(x) in blue by clicking a button using embedded components.

To place the components and configure the plot component:

1. 

Insert a Plot and 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 Plot component, and then select Component Properties.

3. 

In the Plot Expression region, enter plot(sin(x), x=0..10);.

4. 

Click OK.

The Plot component plots sin(x) in the default color (burgundy).

To display a caption on the button:

1. 

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

2. 

In the Caption field, enter Blue Plot, and then click OK.

To edit the action of the button when it is clicked:

1. 

Right-click (Control-click for Macintosh) on Blue Plot, 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( sin(x), x=0..10, color=blue));

Note: Ensure the component name (that is, Plot0) is correct.

3. 

From the File menu, select Save Code to accept all changes.

4. 

From the File menu, select Close Code Editor.

When you click Blue Plot, the color of the plot changes to blue.

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

DocumentTools[Do](%Plot0 = plot(sin(x), x=0..10, color = blue));

 

Example 2 - Launch the ArcLengthTutor and return the plot output in an embedded Plot component.

1. 

Insert a Plot, Label, and Button component in the worksheet.

2. 

Right-click (Control-click for Macintosh) the Label component and select Component Properties.

3. 

In the Caption field, enter Launch the Arc Length Tutor, and then click OK.

4. 

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

5. 

In the Caption field, enter Run Tutor, and then click OK.

6. 

Right-click (Control-click for Macintosh) Run Tutor, and then select Edit Click Action.

7. 

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

Do(%Plot1="Student[Calculus1][ArcLengthTutor]()");

Note: Ensure the component name matches the name of the Plot component.

8. 

From the File menu, select Save Code to accept all changes.

9. 

From the File menu, select Close Code Editor.

 

  

  

 

See Also

CheckBoxComponent, ComboBoxComponent, DataTableComponent, DialComponent, DocumentTools, DocumentTools[Do], DocumentTools[GetProperty], DocumentTools[SetProperty], EmbeddedComponents,  LabelComponent, ListBoxComponent, Maplets[Elements][Button], MathExpressionComponent, MeterComponent, PlotComponent, RadioButtonComponent, RotaryGaugeComponent, SliderComponent, TextAreaComponent, ToggleButtonComponent, 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