Page 1 of 1

Click Legend to Hilite Line on Chart

Posted: Fri Dec 20, 2013 9:03 pm
by townsend
I'm using a line chart with potentially 10 lines. When the user clicks on a element in the Legend, I want the corresponding line on the Chart to become hilited. In order to do this, I would be changing the line width. But since the Legend Buttons are created dynamically, by Animation Engine, I need to be able to use some code to add an On MouseUp handler to each of the buttons, which to increase the line width.

What's the best way of doing this?

Re: Click Legend to Hilite Line on Chart

Posted: Sat Dec 21, 2013 12:46 am
by townsend
Here an example that illustrates one way this can be done.

Code: Select all

on mouseUp
     put "click me" into temp
     create button temp
     set the loc of it to 200,100
     set the width of it to 60
     set the height of it to 30
     set the script of btn "click me" to "on mouseUp" & cr & "beep" & cr & "end mouseUp"
     set the label of btn "click me" to "I'm New"
end mouseUp

Re: Click Legend to Hilite Line on Chart

Posted: Sat Dec 21, 2013 2:52 am
by Simon
Hi townsend,
I wasn't sure when you first asked the question if you knew where the legend icon would be... now I know.
Since they are static why don't you just place transparent buttons on top of them?
Setting scripts is a pain because they are limited when running on a stand alone.

If you hide the buttons when they are not needed then they can't be activated.

Simon

Re: Click Legend to Hilite Line on Chart

Posted: Sat Dec 21, 2013 9:08 am
by malte
You can set a behavior of the button...