MathGroup Archive 2008

[Date Index] [Thread Index] [Author Index]

Search the Archive

Linking EventHandler to a Control Object

  • To: mathgroup at smc.vnet.net
  • Subject: [mg88701] Linking EventHandler to a Control Object
  • From: Todd Allen <genesplicer28 at yahoo.com>
  • Date: Tue, 13 May 2008 07:09:24 -0400 (EDT)

Hi folks,

   Have any of you tried to use the new
(V6)EventHandler command to excute a series of actions
based on input to a control object such as SetterBar?

   I have had success getting Mathematica to update a
displayed list every time the displayed list is
clicked on, but not when I want a control object to be
clicked on to update the displayed list.

   Probably an example would help clarify:

Example 1: WORKS on my computer


test1 = {"Phe", "Ser", "Leu", "Ser", 
  "Val"}; color = Black; trak = "Ser";
EventHandler[
 Dynamic[test1], {"MouseClicked" :> (color = 
     color /. {Black -> Red, Red -> Green, Green ->
Black}; 
    temp1 = Position[test1, trak]; 
    test1 = ReplacePart[test1, temp1 -> Style[trak,
color]];)}]


Example 2: Does NOT work


trak2 = SetterBar[
  Evaluate[Dynamic[trak2]], {"Phe" -> "Phe", "Ser" ->
"Ser", 
   "Leu" -> "Leu", "Val" -> "Val"}]
test2 = {"Phe", "Ser", "Leu", "Ser", "Val"}; color =
Black;
EventHandler[{Dynamic[trak2], 
  Dynamic[test2]}, {"MouseClicked" :> (color = 
     color /. {Black -> Red, Red -> Green, Green ->
Black}; 
    temp2 = Position[test2, trak2]; 
    test2 = ReplacePart[test2, temp2 -> Style[trak2,
color]]; test2)}]


Notice how the SetterBar in example 2 is updated, but
the corresponding list that should be updated is not. 
Its as though the EventHandler command is actually not
"seeing" the mouse click. 

Would you have any thoughts on how to link the input
at the control object to the desired response of
updating a displayed list?

Thanks for any advice you might have!
Todd


      ____________________________________________________________________________________
Be a better friend, newshound, and 
know-it-all with Yahoo! Mobile.  Try it now.  http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ


  • Prev by Date: Re: Flashing Graphs With Manipulate
  • Next by Date: Re: FullForm OK but StandardForm fails
  • Previous by thread: Re: SetOptions[Plot, BaseStyle :> myBaseStyle] does not work
  • Next by thread: Re: Linking EventHandler to a Control Object