Button Component - Maple Programming Help

Online Help

All Products    Maple    MapleSim


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

Button Component

Insert a button in a Standard Maple worksheet or document

 

Description

Component Palette Image

Button Properties

Button Component Examples

Description

• 

The button 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, select the button, and then in the Button context panel, select Edit Click Code 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 context panel. To view the Button context panel select the button component.

• 

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

fontcolor

x

x

color

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

type

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.

  

fontcolor

  

Specifies the font color of the component. The color can be given by RGB values (a list of three integers between 0 and 255) or a string representing a color name, for example, [255,0,0] or “Red”.  The default value is [0,0,0] which corresponds to black.

  

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.

  

type 

  

The type of the component. This returns "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. 

Click on the Plot component to display the Plot context panel on the right side of the worksheet (or document).

3. 

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

 

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

To display a caption on the button:

1. 

Click on the Button component to display the Button context panel.

2. 

In the Caption field, enter Blue Plot.

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

1. 

Click on Blue Plot, 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( sin(x), x=0..10, color=blue));

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

3. 

Click  on the Code Editor toolbar or 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.

with(DocumentTools):

SetProperty("Plot0", value,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. 

Click the Label component to display the context panel.

3. 

In the Caption field, enter Launch the Arc Length Tutor.

4. 

Click the Button component to display the context panel.

5. 

In the Caption field, enter Run Tutor.

6. 

Click Run Tutor, and then select Edit Click Code from the context panel.

7. 

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

SetProperty("Plot1", value, "Student[Calculus1][ArcLengthTutor]()");

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

8. 

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

9. 

From the File menu, select Close Code Editor.

 

  

  

 

See Also

DocumentTools

DocumentTools[GetProperty]

DocumentTools[SetProperty]

EmbeddedComponents

Maplets[Elements][Button]