Re: Widget Event Handling Problem [message #14937] |
Mon, 12 April 1999 00:00 |
davidf
Messages: 2866 Registered: September 1996
|
Senior Member |
|
|
Jason Brookes <jason.brookes@rmsb.u-bordeaux2.fr> writes:
> I have been experiencing an annoying widget-event handling problem. I
> create a widget "sub-panel" on which the user is allowed to set
> (exclusively) one of four possible buttons, each button corresponding to
> a different image. I have included the relevant code from the widget
> creation and event handling functions below. The problem is that
> whenever one of the four buttons is selected, the event handling routine
> is entered twice, AS IF responding to both the previous mouse button
> release, and the current mouse button press (this may or may not be what
> is actually happening). For example, if button_3 is currently set, and
> the user sets button 1, the event handling routine will first execute
> the code corresponding to 'stim_3' in the CASE statement followed by the
> code corresponding to 'stim_1'. I would much rather it executed only the
> code corresponding to 'stim_1'.
> Hope my explanation is clear(ish). Can anybody enlighten me ?
Exclusive buttons do indeed generate both an unselect and select
event. That is, unless, you set the /No_Release keyword on the
buttons, in which case they only generate select events.
> While I'm at it, is there an elegant way of updating the maximum value
> for a floating-point slider ?
No, no elegant way without hacking the code.
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438 E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
|
|
|
Re: Widget Event Handling Problem [message #15017 is a reply to message #14937] |
Mon, 12 April 1999 00:00  |
davidf
Messages: 2866 Registered: September 1996
|
Senior Member |
|
|
I wrote earlier today in response to this question from Jason Brookes:
>> While I'm at it, is there an elegant way of updating the maximum value
>> for a floating-point slider ?
>
> No, no elegant way without hacking the code.
I was thinking about using this as a good example for why you
might want to write compound widgets as objects and I was thinking
about coding it up as an example for the newsgroup. But in examining
the code, I realized that the author of CW_FSLIDER had already
anticipated someone wanting to change the MIN and MAX values.
Unfortunately, his method has never made it into the documentation.
(Oh, don't even start!)
But as it happens, if you want to change the MIN or MAX values
you can do it like this:
Widget_Control, floatingSlider, Set_Value=[newValue, newMin, newMax]
You can also get the current MIN and MAX of the floating slider
by calling the FSLIDER_GET_VALUE function directly (I.e., don't
use the normal WIDGET_CONTROL, floatingSlider, GET_VALUE=thisVal
syntax), like this:
min_max = FSLIDER_GET_VALUE(floatingSlider, /MinMax)
This is VERY non-standard compound widget coding, but typical
of many RSI-supplied routines. Of course, you can get away
with it if you understand what you are doing and I have to
admit that as hard as it is to understand their code most
of the time, the RSI programmers DO know what they are
doing. :-)
Anyway, all of this information is in the header of the
CW_FSLIDER program and you can read it for yourself. Perhaps
it will make it into the IDL documentation in IDL 5.3.
Cheers,
David
P.S. I also got a nice "hack" from my friend Andrew Cool
in Australia. His "Discrete_Slider" code is a floating
slider than can change it's value in discrete units. I have
his permission to put it on my web page if anyone is interested.
--
David Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438 E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
|
|
|