widget_tab: prevent switching? [message #63981] |
Wed, 26 November 2008 01:16  |
Justus Skorps
Messages: 20 Registered: April 2007
|
Junior Member |
|
|
Hi all,
in my GUI I have an widget_tab with different tabs, each containing
only a widget_base with a widget_draw. I need a possibility to
temporary prevent to switch to another tab without disabling the
widget_draw on the current tab. Disabling the whole widget_tab
prevents switching but also disables button_events from the
widget_draw of the current tab. The only workaround I found so far
(switch back to the current tab when a tab event occurs) leads to some
other problems and a lot of code work...
I also tried to disable the bases of each tabs or set the tab_mode to
0, nothing works...
Anyone knows a way to prevent the switching?
thanx,
Justus
|
|
|
|
|
Re: widget_tab: prevent switching? [message #64114 is a reply to message #63981] |
Wed, 26 November 2008 09:20   |
Spon
Messages: 178 Registered: September 2007
|
Senior Member |
|
|
On Nov 26, 9:16 am, Justus Skorps <ju...@gmx.de> wrote:
> Hi all,
>
> in my GUI I have an widget_tab with different tabs, each containing
> only a widget_base with a widget_draw. I need a possibility to
> temporary prevent to switch to another tab without disabling the
> widget_draw on the current tab. Disabling the whole widget_tab
> prevents switching but also disables button_events from the
> widget_draw of the current tab. The only workaround I found so far
> (switch back to the current tab when a tab event occurs) leads to some
> other problems and a lot of code work...
>
> I also tried to disable the bases of each tabs or set the tab_mode to
> 0, nothing works...
>
> Anyone knows a way to prevent the switching?
>
> thanx,
> Justus
Ok, this is the least inelegant solution I've come up with so far. It
effectively switches back to the current tab when a tab event occurs
while the tab is locked - which was your original workaround. Making
use of the tab widget's own uvalue to store info about current and
locked tabs makes it a managable enough proposition, in my opinion.
PRO TabTest_Tab_Dispatch, Event
Widget_Control, Event.ID, Get_UValue = TabInfo
If TabInfo.Locked Then $
Widget_Control, Event.ID, Set_Tab_Current = TabInfo.Current $
Else Begin
Case Event.Tab of
0:
1:
2: Begin
; Lock this tab
TabInfo.Current = 2L
TabInfo.Locked = 1
Widget_Control, Event.ID, Set_UValue = TabInfo
Widget_Control, UVal.Draw2, Sensitive = 1
; Do some stuff and switch TabInfo.Locked back to 0
; when it's safe to reactivate the tabs
End
EndCase
EndElse
END
PRO TabTest_Done, Event
Widget_Control, Event.Top, Get_UValue = UVal
; Desensitize draw widget
Widget_Control, UVal.Draw2, Sensitive = 0
; Unlock tab widget
Widget_Control, UVal.Tab, Get_UValue = TabInfo
TabInfo.Locked = 0
Widget_Control, UVal.Tab, Set_UValue = TabInfo
END
PRO Tabtest_Foo, Event
Print, 'Event Generated'
END
PRO TabTest
TLB = Widget_Base(Col = 1)
Tab = Widget_Tab(TLB, $
Event_Pro = 'TabTest_Tab_Dispatch', $
UVALUE = {Current : 0L, Locked : 0} )
Base0 = Widget_Base(Tab)
Draw0 = Widget_Draw(Base0, XSize = 200, YSize = 200, $
/Button_Events, Event_Pro = 'Tabtest_Foo')
Base1 = Widget_Base(Tab)
Draw1 = Widget_Draw(Base1, XSize = 200, YSize = 200, $
/Button_Events, Event_Pro = 'Tabtest_Foo')
Base2 = Widget_Base(Tab)
Draw2 = Widget_Draw(Base2, XSize = 200, YSize = 160, $
/Button_Events, Event_Pro = 'Tabtest_Foo')
Btn = Widget_Button(Base2, Value = 'Done', $
Event_Pro = 'TabTest_Done')
Widget_Control, TLB, /Realize
UVal = { Tab : Tab, $
Draw2 : Draw2 }
Widget_Control, TLB, Set_UValue = UVal
XManager, 'TabTest', TLB
END
|
|
|
Re: widget_tab [message #64242 is a reply to message #63981] |
Thu, 11 December 2008 08:09  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
steverajiv writes:
> Is there any way to change the order of tabs using widget_control or
> widget_info (e.g., swap tab1 and tab2 etc..)
I don't think there is any way to change the order of the
tabs. I suppose you could try rebuilding them in a different
order, but it hardly seems worth the effort.
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
|
|
|