Page 1 of 1

Re: Rightclick support for ListViewGadget

Posted: Wed Jan 23, 2013 2:06 pm
by Shardik
Guimauve wrote:I will have to check if it's possible to do something similar with GTK+

Code: Select all

ProcedureC GdkEventHandler(*EventButton.GdkEventButton, UserData.I)
  Protected *ListView.GtkWidget

  If *EventButton\type = #GDK_BUTTON_PRESS
    *ListView = GadgetID(0)
    
    If *ListView\window = gdk_window_get_parent_(*EventButton\window)
      If *EventButton\button = 3
        Debug "Right click detected"
      EndIf
    EndIf
  EndIf
  
  gtk_main_do_event_(*EventButton)
EndProcedure 

OpenWindow(0, 200, 100, 220, 140, "Detect right click", #PB_Window_SystemMenu)
ListViewGadget(0, 10, 10, 200, 120)

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

gdk_event_handler_set_(@GdkEventHandler(), 0, 0)

Repeat
Until  WaitWindowEvent() = #PB_Event_CloseWindow
In PB 5.10 you may even generate the missing #PB_EventType_RightClick with the new PostEvent() command and evaluate left and right clicks in your standard event loop:

Code: Select all

#Window = 0
#ListView = 0

ProcedureC GdkEventHandler(*EventButton.GdkEventButton, UserData.I)
  Protected *ListView.GtkWidget

  If *EventButton\type = #GDK_BUTTON_PRESS
    *ListView = GadgetID(#ListView)
    
    If *ListView\window = gdk_window_get_parent_(*EventButton\window)
      If *EventButton\button = 3
        PostEvent(#PB_Event_Gadget, #Window, #ListView, #PB_EventType_RightClick)
      EndIf
    EndIf
  EndIf
  
  gtk_main_do_event_(*EventButton)
EndProcedure 

OpenWindow(#Window, 200, 100, 220, 140, "Detect right click", #PB_Window_SystemMenu)
ListViewGadget(#ListView, 10, 10, 200, 120)

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

gdk_event_handler_set_(@GdkEventHandler(), 0, 0)

Repeat
  Select WaitWindowEvent()
    Case #PB_Event_CloseWindow
      Break
    Case #PB_Event_Gadget
      If EventGadget() = #ListView
        Select EventType()
          Case #PB_EventType_LeftClick
            Debug "Left click on line " + Str(GetGadgetState(#ListView) + 1)
          Case #PB_EventType_RightClick
            Debug "Right click on line " + Str(GetGadgetState(#ListView) + 1)
        EndSelect
      EndIf
  EndSelect
ForEver

Re: Rightclick support for ListViewGadget

Posted: Sat Mar 09, 2013 10:50 pm
by Andre
+1 for rightclick support at ListViewGadget and other eventtypes, already supported by ListIconGadget.

Re: Rightclick support for ListViewGadget

Posted: Sun Mar 10, 2013 8:14 am
by davido
+1 for rightclick support at ListViewGadget and other eventtypes, already supported by ListIconGadget.

Re: Rightclick support for ListViewGadget

Posted: Sun Mar 10, 2013 10:37 am
by Ulix
+1 for RightClick and RightDoubleClick and cross-platform !

Re: Rightclick support for ListViewGadget

Posted: Sun Mar 10, 2013 11:23 am
by Joris
+1 for RightClick

As PB starter I haven't tested all Gadget's to know what events they can accept, but LeftClick and RightClick should be a minimum for all in my opinion. Cross-platform.
LeftClick to select wherever possible and RightClick to connect a popup menu or label for info or add-delete-insert-copy-move actions etc. (like insert a column...for ListView).

Re: Rightclick support for ListViewGadget

Posted: Sun Mar 10, 2013 12:27 pm
by Polo
+1, been limited by this before!

Re: Rightclick support for ListViewGadget

Posted: Sat Mar 23, 2013 7:58 am
by charvista
+1 RightClick

But not sure for what a DoubleRightClick might be useful... But implementation is OK.