ContainerGadget fires #PB_EventType_LeftClick on resize
Posted: Wed Mar 05, 2014 12:36 pm
Hi,
today i noticed that the ContainerGadget fires an #PB_EventType_LeftClick when the size will be changed programmatically. This is very helpful to reorganize embedded gadgets inside the container.
In the help file i did not find any information about that, so it would be very helpful if the supported events will be described in the PB help document.
From my opinion, the #PB_Eventtype_LeftClick is wrong, because resizing has nothing to do with mouse clicks. #PB_EventType_Change would better fit, or #PB_EventType_SizeItem, or a new event type #PB_EventType_SizeGadget.
Some code to test:
Best regards
Uwe
today i noticed that the ContainerGadget fires an #PB_EventType_LeftClick when the size will be changed programmatically. This is very helpful to reorganize embedded gadgets inside the container.
In the help file i did not find any information about that, so it would be very helpful if the supported events will be described in the PB help document.
From my opinion, the #PB_Eventtype_LeftClick is wrong, because resizing has nothing to do with mouse clicks. #PB_EventType_Change would better fit, or #PB_EventType_SizeItem, or a new event type #PB_EventType_SizeGadget.
Some code to test:
Code: Select all
Structure CustomGadgetData
Button1.i
Button2.i
EndStructure
Procedure CustomGadgetResize()
g = EventGadget()
*data.CustomGadgetData = GetGadgetData(g)
w = GadgetWidth(g)
h = GadgetHeight(g) / 2
ResizeGadget(*data\Button1, #PB_Ignore, #PB_Ignore, w, h)
ResizeGadget(*data\Button2, #PB_Ignore, h, w, h)
EndProcedure
Procedure CustomGadget(Gadget, X, Y, W, H)
ContainerGadget(Gadget, x, y, w, h, #PB_Container_BorderLess)
*data.CustomGadgetData = AllocateMemory(SizeOf(CustomGadgetData))
SetGadgetData(Gadget, *data)
h / 2
*data\Button1 = ButtonGadget(#PB_Any, 0, 0, w, h, "1")
*data\Button2 = ButtonGadget(#PB_Any, 0, h, w, h, "2")
CloseGadgetList()
BindGadgetEvent(Gadget, @CustomGadgetResize(), #PB_EventType_LeftClick)
EndProcedure
If OpenWindow(0, 0, 0, 300, 200, "Test", #PB_Window_SystemMenu | #PB_Window_ScreenCentered | #PB_Window_SizeGadget)
CustomGadget(0, 10, 10, 280, 180)
Repeat
Select WaitWindowEvent()
Case #PB_Event_Gadget
Case #PB_Event_SizeWindow
ResizeGadget(0, #PB_Ignore, #PB_Ignore, WindowWidth(0) - 20, WindowHeight(0) - 20)
Case #PB_Event_CloseWindow
Break
EndSelect
ForEver
EndIf
Uwe