SetGadgetState() on ListIconGadget() generates #PB_EventType_Change
Posted: Thu Dec 04, 2025 6:15 am
Why? If I do the same with ComboGadget(), no event is triggered. On Windows it works as expected (no events are triggered in general, but on Windows I wonder why SetGadgetState initially deselects the entry - with a separate event! - before a new is selected). No idea if this is a bug or or another inconsistency between Windows and macOS that PureBasic users have to live with (In that case, the question would be why the PB command SetGadgetState does not automatically remove this inconsistency.)... Thank you for any clarification
Output Windows:
Output Windows:
Output macOS:ListIcon clicked:
---> "ListIconGadget changed to -1" (Why a deselection is forced before a new selection?)
---> "ListIconGadget changed to 3"
Combobox clicked:
---> "ComboBoxGadget changed to 3"
Button Clicked:
---> "Button pressed"
ListIcon clicked:
---> "ListIconGadget changed to 3"
Combobox clicked:
---> "ComboBoxGadget changed to 3"
Button Clicked:
---> "Button pressed"
---> "ListIconGadget changed to 3" (Why an #PB_EventType_Change is triggered with SetGadgetState?)
Code: Select all
#li = 0
#cb = 1
#bt = 2
Procedure li()
Debug "ListIconGadget changed to " + Str(GetGadgetState(#li))
EndProcedure
Procedure cb()
Debug "ComboBoxGadget changed to " + Str(GetGadgetState(#cb))
EndProcedure
Procedure bt()
Debug "Button pressed"
Repeat
rnd = Random(9)
Until rnd <> GetGadgetState(#li) ; not the same slot
SetGadgetState(#li, rnd)
Repeat
rnd = Random(9)
Until rnd <> GetGadgetState(#cb) ; not the same slot
SetGadgetState(#cb, rnd)
EndProcedure
OpenWindow(0, 0, 0, 600, 400, "ListIcon Example", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ListIconGadget(#li, 5, 5, 400, 300, "Name", 100, #PB_ListIcon_FullRowSelect | #PB_ListIcon_AlwaysShowSelection)
AddGadgetColumn(#li, 1, "Address", 250)
ComboBoxGadget(#cb, 5, 320, 300, 26)
ButtonGadget(#bt, 450, 20, 100, 40, "RND")
For i = 0 To 9
AddGadgetItem(#li, i, Str(i) + " Harry Rannit"+Chr(10)+"12 Parliament Way, Battle Street, By the Bay")
AddGadgetItem(#cb, i, Str(i) + " Harry Rannit, 12 Parliament Way, Battle Street, By the Bay")
Next i
SetGadgetState(#li, 0)
SetGadgetState(#cb, 0)
BindGadgetEvent(#li, @li(), #PB_EventType_Change)
BindGadgetEvent(#cb, @cb(), #PB_EventType_Change)
BindGadgetEvent(#bt, @bt())
Repeat
Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow