Maybe it would be more to the point to tell you what I am doing.
I want to click on a listview line to 'edit' the line (closes the window) or use a menu command to highlight several lines. The way it works now, when I use the menu command, I get the highlighting ok but it is followed with 'editing' the line which closes the listview window and ruins the whole effect. As I've got it working now, I use the menu command and then after highlighting the lines I have to do While WindowEvent():Wend to keep the 'editing' from kicking-in... well, it works.
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")
SetGadgetItemState(0,1,1) ; rem out and no events!
Repeat
event=WaitWindowEvent()
Select event
Case #PB_Event_Gadget
;assume gadget is #0
Debug "new Event="+Str(event)+" EventType()="+Str(EventType())
Select EventType()
Case #PB_EventType_Change;#PB_EventType_LeftClick;,768 ; 768 works for deselecting line
Debug "Line clicked on = "+Str(GetGadgetState(0))
For x=0 To 3
Debug " Item "+Str(x)+" = "+Str(GetGadgetItemState(0,x))
Next
Case #PB_EventType_LeftClick
Debug "Left click = "+Str(GetGadgetState(0))
Case #PB_EventType_LeftDoubleClick
Debug "Double click = "+Str(GetGadgetState(0))
EndSelect
Debug "____"
EndSelect
Until event = #PB_Event_CloseWindow
(later)
I've also noticed that, if only one line is selected and you #PB_EventType_LeftDoubleClick on a line then GetGadgetState() will give the line number but if more than one line is selected then GetGadgetState() always gives a -1. It would be useful to have the #PB_EventType_LeftDoubleClick give you the line that you are clicking on.