| Re: widget_control and event generation [message #53393 is a reply to message #53391] |
Sun, 15 April 2007 12:43   |
pdoherty
Messages: 8 Registered: April 2007
|
Junior Member |
|
|
On Apr 15, 4:15 pm, David Fanning <n...@dfanning.com> wrote:
> pedohe...@earthlink.net writes:
>> When I use the following code to switch the currently selected tab in
>> a widget_tab:
>
>> widget = widget_info(info.tlb, find_by_uname='plot_tab')
>> oldtab = widget_info(widget, /tab_current)
>> widget_control, widget, set_tab_current=7
>
>> Do I generate an event?
>
> No, you don't generate an event. But I could believe that
> if you are using a button click to switch tabs that you
> may not be accounting for both the button DOWN and the button
> UP event in your event handler.
That's what I thought. The general idea is that if I press the right
mouse
button the plot_tab switches to a different tab, makes some plots as I
move
the cursor around, and then when I release the right button the tab
switches
back to the original tab. Here's the relevant code (edited) :
; handle right button press events
if ((event.type EQ 0) AND (event.press EQ 4)) then begin
info.mouse_right_down = 1
widget = widget_info(info.tlb, find_by_uname='plot_tab')
info.oldtab = widget_info(widget, /tab_current)
widget_control, widget, set_tab_current=7
endif
; handle right button release events
if ((event.type EQ 1) AND (event.release EQ 4)) then begin
info.mouse_right_down = 0
widget = widget_info(info.tlb, find_by_uname='plot_tab')
widget_control, widget, set_tab_current=info.oldtab
endif
I think I have taken into account DOWN vs UP events. What's strange is
that when I push the button DOWN, and before I release, my event
handler
catches an event for the widget with the uvalue = 'plot_tab', as in
widget_control, event.id, get_uvalue=widget
case widget of
'plot_tab' : ccd_plots, info
etc...
It's as if the system thinks I have clicked on one of the tabs even
though
all I have done is selected a new tab using widget_control.
No doubt, it's my fault. Computers always do what we tell them to do
(the
bas****s). It's just that I don't understand that I've told it to do
this.
- Peter Doherty
|
|
|
|