Why ListIcon/View scrollbar event?

Mac OSX specific forum
WilliamL
Addict
Addict
Posts: 1255
Joined: Mon Aug 04, 2008 10:56 pm
Location: Seattle, USA

Why ListIcon/View scrollbar event?

Post 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?
Last edited by WilliamL on Mon Jan 26, 2009 9:14 pm, edited 2 times in total.
MacBook Pro-M1 (2021), Tahoe 26.1, PB 6.30b2
USCode
Addict
Addict
Posts: 924
Joined: Wed Mar 24, 2004 11:04 pm
Location: Seattle

Post 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.
WilliamL
Addict
Addict
Posts: 1255
Joined: Mon Aug 04, 2008 10:56 pm
Location: Seattle, USA

Post by WilliamL »

Ok, I see. Several gadgets have 'EventType()'s attached to them. I guess with the ListView/IconGadget the 'EventType()' is required.
MacBook Pro-M1 (2021), Tahoe 26.1, PB 6.30b2
USCode
Addict
Addict
Posts: 924
Joined: Wed Mar 24, 2004 11:04 pm
Location: Seattle

Post 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.
Post Reply