Re: Re: SetterBar/ButtonBar, Dynamic and the visual
- To: mathgroup at smc.vnet.net
- Subject: [mg104404] Re: [mg104364] Re: SetterBar/ButtonBar, Dynamic and the visual
- From: Jason Ledbetter <jasonbrent at gmail.com>
- Date: Fri, 30 Oct 2009 02:20:31 -0500 (EST)
- References: <hc92ef$een$1@smc.vnet.net> <200910290756.CAA20005@smc.vnet.net>
Albert, That was the missing piece.... although it turns out that SetterBar acts oddly if it is just passed one choice (which my dataset sometimes does...). Thanks again. -jbl On Thu, Oct 29, 2009 at 3:56 AM, Albert Retey <awnl at gmx-topmail.de> wrote: > Jason Ledbetter wrote: > > Folk, > > > > Once again I'm trying to understand some UI nuances in Mathematica... > > > > I'm trying to use SetterBar or ButtonBar as selectors for portions of a > > dataset with an action attached. This basically works however when I have > an > > action associated with either, the selected button doesn't visually > appear > > selected when clicked... > > > > A sample of what I'm doing is below; my basic goal is to use either of > the > > last 2 of these four examples but have the button highlighting act like > the > > first two examples. > > > > Clear[x1, x2, y1, checkSwitch]; > > (* appears to force no default selection w/ SetterBar *) > > (x1 = Null; > > x2 = Null; y1 = Null;) > > choices = {"one", "two", "three"}; > > checkSwitch[button_] := Switch[button, _, Print[button]] > > Panel[{Column[{ > > Style["SetterBars", Bold], > > Style["No Dynamic, button stays highlighted", Italic], > > SetterBar[x1, # -> # & /@ choices], > > Style["Dynamic WITHOUT action, button stays highlighted", Italic], > > Row[{SetterBar[Dynamic[y1], # -> # & /@ choices], Dynamic[y1]}], > > Style["Dynamic with action, button does not stay highlighted", > Italic], > > SetterBar[Dynamic[x2, checkSwitch[#] &], # -> # & /@ choices], > > Style["ButtonBars", Bold], > > Style["Dynamic with action, button does not stay highlighed", > Italic], > > ButtonBar[# :> checkSwitch[#] & /@ choices] > > }] > > }] > > > > > > TIA, > > > > > > -jbl > > > > > Your second to last example should be: > > SetterBar[ > Dynamic[x2, (checkSwitch[#]; x2 = #) &], # -> # & /@ choices] > > you have to set x2 explicitly when using the two argument form of Dynamic. > > hth, > > albert > >
- References:
- Re: SetterBar/ButtonBar, Dynamic and the visual appearance of "selected"
- From: Albert Retey <awnl@gmx-topmail.de>
- Re: SetterBar/ButtonBar, Dynamic and the visual appearance of "selected"