For reference: PureBasic v4.02 (Windows - x86) / Win-XP Pro-SP2
I am trying some code for when a tab in one of several panels get focus.
The only related thread I found is:
http://www.purebasic.fr/english/viewtopic.php?t=8876
Old and no help.
I know that:
Code: Select all
Type = EventType()
;The following values are possible,
;if an event of the type #PB_Event_Gadget (library Gadget) or
; #PB_Event_SysTray (library Systray) occurs:
;
; #PB_EventType_LeftClick : Left mouse button click
; #PB_EventType_RightClick : right mouse button click
; #PB_EventType_LeftDoubleClick : Left mouse button double click
; #PB_EventType_RightDoubleClick: Right mouse button double click
; #PB_EventType_Focus : Get the focus.
; #PB_EventType_LostFocus : Lose the focus.
; #PB_EventType_Change : Content change.
;
Code: Select all
Event = WaitWindowEvent()
; Case #PB_Event_Menu : a menu has been selected
; Case #PB_Event_Gadget : a gadget has been pushed
; Case #PB_Event_SysTray : an icon in the systray zone was clicked
; Case #PB_Event_CloseWindow : the window close gadget has been pushed
; Case #PB_Event_Repaint : the window content has been destroyed And must be repained (useful For 2D graphics operations)
; Case #PB_Event_SizeWindow : the window has been resized
; Case #PB_Event_MoveWindow : the window has been moved
; Case #PB_Event_ActivateWindow : the window has been activated (got the focus)
Gadget = EventGadget()
Window = EventWindow()
Type = EventType()
I have posted my code below and since I am not a full time programmer, maybe I missed something.
What happens is that when you click/select 'Tab 1' and then 'Tab 4' nothing happens.
Select another tab and you will see the changes in the debug window.
Code follows:
Code: Select all
Global Window_0, Panel_0, Panel_1
;
; Start Enumeration for gadget's
;
Enumeration 1
#WindowID0
#PanelID0
#PanelID1
#Max_Obj_ID ; This Constant is always last, used for DIM of structured array
EndEnumeration
Structure VisualDesignerGadgets
Handle_ID.l
EventFunction.l
EndStructure
Global Dim EventProcedures.VisualDesignerGadgets(#Max_Obj_ID)
Procedure Panel_1_Event(Window, Event, Gadget, Type)
Which_Panel.l
Which_Tab.l
Debug "Panel_1"
Which_Panel = gadget
Which_Tab = GetGadgetState(gadget)
Debug "Panel(GadgetID) = " + Str(which_panel) + ", Tab = " + Str(Which_Tab) + " and Type = " + Str(type) + " ."
EndProcedure
Procedure Panel_0_Event(Window, Event, Gadget, Type)
Which_Panel.l
Which_Tab.l
Debug "Panel_0"
Which_Panel = gadget
Which_Tab = GetGadgetState(gadget)
Debug "Panel(GadgetID) = " + Str(which_panel) + ", Tab = " + Str(Which_Tab) + " and Type = " + Str(type) + " ."
EndProcedure
Procedure RegisterGadgetEvent(Gadget, *Function, HandleID)
EventProcedures(Gadget)\Handle_ID = HandleID
EventProcedures(Gadget)\EventFunction = *Function
EndProcedure
Procedure CallEventFunction(Window, Event, Gadget, Type)
CallFunctionFast(EventProcedures(Gadget)\EventFunction, Window, Event, Gadget, Type)
EndProcedure
Procedure Open_Window_0()
Window_0 = OpenWindow(#WindowID0, 235, 105, 400, 200, "Window 0", #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget | #PB_Window_SizeGadget | #PB_Window_TitleBar | #PB_Window_ScreenCentered | #PB_Window_WindowCentered )
If Window_0
If CreateGadgetList(WindowID(#WindowID0))
Panel_0 = PanelGadget(#PanelID0, 12, 90, 1230, 660)
AddGadgetItem(#PanelID0, 1, "Tab 1")
Panel_1 = PanelGadget(#PanelID1, 6, 8, 1210, 620)
AddGadgetItem(#PanelID1, 1, "Tab 4")
AddGadgetItem(#PanelID1, 2, "Tab 5")
CloseGadgetList()
Panel_1 = GadgetID(#PanelID1)
RegisterGadgetEvent(#PanelID1, @Panel_1_Event(),Panel_1)
AddGadgetItem(#PanelID0, 2, "Tab 2")
AddGadgetItem(#PanelID0, 3, "Tab 3")
CloseGadgetList()
Panel_0 = GadgetID(#PanelID0)
RegisterGadgetEvent(#PanelID0, @Panel_0_Event(),Panel_0)
EndIf
EndIf
EndProcedure
Open_Window_0()
Repeat
Event = WaitWindowEvent()
Gadget = EventGadget()
Window = EventWindow()
Type = EventType()
Select Event
Case #PB_Event_Gadget
CallEventFunction(Window, Event, Gadget, Type)
EndSelect
Until Event = #PB_Event_CloseWindow
End
I really don't think I have found a bug with such a basic capability.
I must be missing something here.
I thank you in advance for any insight to this.
Harry0