Page 1 of 1

Why ListIcon/View scrollbar event?

Posted: Mon Jan 26, 2009 6:48 pm
by WilliamL
In the ListIcon and ListView gadget, I click on a line and I get the line number back using 'EventGadget()'. I move the scrollbar and I get the same line number back. What is the point in that? I have to use 'EventType()' and '#PB_EventType_LeftClick' just to avoid the scrollbar event. It would be simpler just to have the scrollbar ignored in 'EventGadget()'.

Code: Select all

If OpenWindow(0, 0, 0, 270, 140, "ListViewGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
    ListViewGadget(0, 10, 10, 250, 120)
    For a = 1 To 12
      AddGadgetItem (0, -1, "Item " + Str(a) + " of the Listview")
    Next

    Repeat
        event = WaitWindowEvent()
        Select event
        Case #PB_Event_Gadget
            MessageRequester("Move the scrollbar",Str( GetGadgetState(0)+1))
        EndSelect
    Until event = #PB_Event_CloseWindow
EndIf
Why does it work this way?

Posted: Mon Jan 26, 2009 9:06 pm
by USCode
EventGadget() tells you which gadget triggered the event, it should return the Gadget#, not the selected item number.
EventType() would then tell you what action the user took to trigger the event.
You would then use GetGadgetState() on that gadget to determine which item was selected.

Posted: Mon Jan 26, 2009 9:20 pm
by WilliamL
Ok, I see. Several gadgets have 'EventType()'s attached to them. I guess with the ListView/IconGadget the 'EventType()' is required.

Posted: Tue Jan 27, 2009 4:40 am
by USCode
Here's the event types from the doc for ListIconGadget, this should help:
The following events are supported through EventType():

#PB_EventType_LeftClick: left click on an item, or a checkbox was checked/unchecked
#PB_EventType_LeftDoubleClick
#PB_EventType_RightClick
#PB_EventType_RightDoubleClick
#PB_EventType_Change: the current item changed
#PB_EventType_DragStart: the user tried to start a Drag & Drop operation.