Using Embedded Components

The Maple 10 Help on Embedded Component provides examples for all components that I have found to be easy to follow and understand except for the example relating to the Text Area component.

With this example, one should be able to perform the action of retrieving an expression entered in a text area and displaying this expression as 2-D Math in a math container upon selecting Enter.

The instruction to perform this action is to enter the following in the Action When Contents Change field of the Text Area. This instruction is: SetProperty 'MathContainer0', 'value',parse(GetProperty('TextArea0', 'value')));

I have not been able to get this example. Could someone provide comments that would help me to understand this example, and more specifically how it could be usefull.

Tks. JG

Doug Meade's picture

Works for me (example provided)

JG,

This works for me. The key is that the action is not applied until the cursor is moved outside the text area. To make matters even worse, it does not get applied if you move the cursor into the math container. But, if you click anywhere around this box, the action is applied.

Here's the link to the worksheet I just uploaded.
View 178_EmbeddedComponentExample.mw on MapleNet or Download 178_EmbeddedComponentExample.mw
View file details

Doug

---------------------------------------------------------------------
Douglas B. Meade
Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.edu       
Phone:  (803) 777-6183         URL:    http://www.math.sc.edu/~meade/
Robert Israel's picture

Explanation

The value of the TextArea is a string, namely what is typed in that area.

GetProperty('TextArea0', 'value')

gets that string.
Then

parse(...)

takes that string and turns it into a Maple expression (but without evaluating the expression).
And finally

SetProperty('MathContainer0', 'value',...)

makes that Maple expression (or rather its typeset version) the value of the Math container.

One thing that's annoying: in order to have this take effect, you have to click somewhere in the worksheet or document outside the Text Area and Math Container. You might include a button
for people to click on after editing the Text Area. The button doesn't have to actually do anything.

If you want to have the expression evaluated instead of just typeset, replace that SetProperty command with

SetProperty('MathContainer0', 'value',
eval(parse(GetProperty('TextArea0', 'value'))));

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
}