De-select Multi-ListViewGadget
Posted: Wed Oct 14, 2009 4:25 am
I'm confused. Below is the way I understand how the events work for the ListViewGadget(). I am assuming that I have to use EventType() before reading the GetGadgetItemState(,) and that would normally mean that I would look for a #PB_EventType_LeftClick then read the item state. That works fine for selecting a line but if I want to deselect a line it doesn't work as a #PB_EventType_LeftClick but as 768. If I substitute 768 for #PB_EventType_LeftClick I can select and de-select without problems. What is going on?
Code: Select all
OpenWindow(0, 100, 100, 300, 200, "ListView")
ListViewGadget(0, 100, 50, 100, 100, #PB_ListView_MultiSelect)
AddGadgetItem(0, -1, "Item 1")
AddGadgetItem(0, -1, "Item 2")
AddGadgetItem(0, -1, "Item 3")
AddGadgetItem(0, -1, "Item 4")
Repeat
event=WaitWindowEvent()
Select event
Case #PB_Event_Gadget
;assume gadget is #0
Debug "EventType()="+Str(EventType())
Select EventType()
Case #PB_EventType_Change ; works for selecting/deselecting line instead of #PB_EventType_LeftClick which only works with selecting
Debug "Line clicked on = "+Str(GetGadgetState(0))
For x=0 To 3
Debug " Item "+Str(x)+" = "+Str(GetGadgetItemState(0,x))
Next
EndSelect
EndSelect
Until event = #PB_Event_CloseWindow