Run this app, and then press Space a few times. Items 5 to 9 toggle their checkbox, but not item 10. However, if you click the Button so it gets the focus, and then press Space, then yes, item 10 now also gets included with the toggling, which is what I want.
So how can I include item 10 without switching the focus away from the ListIconGadget?
Code: Select all
If OpenWindow(0, 0, 0, 640, 400, "ListIconGadgets", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ListIconGadget(0, 10, 10, 620,350, "Column 0", 100, #PB_ListIcon_AlwaysShowSelection|#PB_ListIcon_FullRowSelect|#PB_ListIcon_GridLines| #PB_ListIcon_CheckBoxes|#PB_ListIcon_MultiSelect )
ButtonGadget(1,10,370,100,25,"Button")
For c = 1 To 6
AddGadgetColumn(0, c, "Column " + Str(c), 100)
Next
For r = 0 To 15
AddGadgetItem(0, r, " Item "+Str(r)+Chr(10)+"Item "+Str(r)+Chr(10)+"Item 3"+Chr(10)+"Item 4")
Next
For r = 5 To 10
SetGadgetItemState(0, r, #PB_ListIcon_Checked | #PB_ListIcon_Selected)
Next
SetActiveGadget(0)
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Quit = 1
Case #WM_KEYDOWN
If GetAsyncKeyState_(#VK_SPACE) & $8000
For r=5 To 10
If GetGadgetItemState(0,r) & #PB_ListIcon_Selected
If GetGadgetItemState(0,r) & #PB_ListIcon_Checked
c=~#PB_ListIcon_Checked
Else
c=#PB_ListIcon_Checked
EndIf
SetGadgetItemState(0,r,c|#PB_ListIcon_Selected)
EndIf
Next
EndIf
EndSelect
Until Quit = 1
EndIf