Re: Change Default Button Method
- To: mathgroup at smc.vnet.net
- Subject: [mg110804] Re: Change Default Button Method
- From: Albert Retey <awnl at gmx-topmail.de>
- Date: Wed, 7 Jul 2010 07:42:50 -0400 (EDT)
- References: <i0u00b$jpo$1@smc.vnet.net>
Hi,
> I frequently use buttons in my projects, and almost always use the
> Mehod->"Queued" option. Is there a way to change the default setting so I
> don't have to type this every time? It seems like this should be possible
> using a stylesheet, but I don''t know the syntax. Any help would be
> appreciated.
in principle it would be possible to set Options for Button globally,
like this:
SetOptions[Button,Method->"Queued"]
but since Button might be used at many places you might break things
outside of your package if you do so. I'd probably rather define a
myButton as follows and use that in your projects, then you'd be sure to
not break other code...
SetAttributes[myButton,HoldRest];
Options[myButton]=Replace[Options[Button],_[Method,_]:>(Method->"Queued"),{1}]
myButton[label_,code_,opts:OptionsPattern[]]:=With[{
newopts=Sequence@@Flatten[{opts,Options[myButton]}]
},
Button[label,code,newopts]
]
hth,
albert