Page 1 of 1

ListViewGadget and #PB_EventType_RightClick

Posted: Wed May 16, 2007 8:24 pm
by Kiffi
Hello,

it would be nice, if a ListViewGadget also receives a #PB_EventType_RightClick

Code: Select all

OpenWindow(0, #PB_Ignore, #PB_Ignore, 100, 100, "EventType()")
CreateGadgetList(WindowID(0))
ListViewGadget(0,  5, 5, 90, 90)

For i = 0 To 5
  AddGadgetItem(0, -1, "item no"+Str(i))
Next

Repeat
  Select WaitWindowEvent()
    Case #PB_Event_CloseWindow : Break
    Case #PB_Event_Gadget
      If  EventGadget() = 0

        Select EventType()
          
          Case #PB_EventType_LeftClick  : Debug "LeftClick"  ; This works
          Case #PB_EventType_RightClick : Debug "RightClick" ; This unfortunately not 
            
        EndSelect
        
      EndIf
  EndSelect
ForEver
TIA & Greetings ... Kiffi

Posted: Mon Jun 04, 2007 6:03 am
by Criss

Code: Select all

#LB_ITEMFROMPOINT = $1A9

If OpenWindow(0,0,0,290,200,"", #PB_Window_SystemMenu|#PB_Window_ScreenCentered) And CreateGadgetList(WindowID(0))
  ListViewGadget(0,20,35,250,120)
  For a=1 To 12
    AddGadgetItem (0,-1,"Item "+Str(a)+" of the Listview")
  Next
  SetGadgetState(0,9)
EndIf

Repeat

  Event = WaitWindowEvent()

  If Event = #WM_RBUTTONDOWN
    GetCursorPos_(@cursor_pos.POINT)
    ScreenToClient_(GadgetID(0),@cursor_pos)
    cpos = cursor_pos\x + cursor_pos\y << 16 ; x AND y are passed as lparam
    itemNum = SendMessage_(GadgetID(0), #LB_ITEMFROMPOINT, 0, cpos)

    If itemNum <= CountGadgetItems(0)-1 ; itemNum is zero based
      SetGadgetState(0, itemNum)
    EndIf

  EndIf


Until Event = #PB_Event_CloseWindow
End

Posted: Mon Jun 04, 2007 9:49 am
by Kiffi
@Criss: Certainly it is possible with Windows-API, but i would prefer, if PB
supports this eventtype native.

Greetings ... Kiffi

Posted: Mon Jun 04, 2007 10:08 am
by PB
I think he's just providing a solution until it can become native. ;)

Posted: Tue Aug 28, 2007 5:59 am
by NoahPhense
It's pretty code.. and it works. Good thing I checked here after 4 hours
of trying to make it work that 'pb' way. Hope this is something on the
fix-list.

- np