Page 1 of 1

Rightclick support for ListViewGadget

Posted: Tue Aug 07, 2007 11:04 pm
by kenmo
Not a big deal, but could ListViewGadgets support the right click event type without the need for API? I couldn't figure out why my code wasn't working until I read that ListView only fires left click events.

Re: Rightclick support for ListViewGadget

Posted: Sun Oct 25, 2009 8:18 pm
by WilliamL
Would like to ask again to add the rightclick for the ListView gadget.

Re: Rightclick support for ListViewGadget

Posted: Sun Oct 25, 2009 10:23 pm
by Little John
I would appreciate that, too.

Regards, Little John

Re: Rightclick support for ListViewGadget

Posted: Sun Jan 20, 2013 1:46 pm
by Guimauve
Hello everyone,

Sorry to re-open a old topic, I prefer to post here instead to create a new one. I'm working on professional project and I for one element to display I wish to use a ListViewGadget() what is my surprise when I try to use a Right Mouse Click to display a Popup Menu. It didn't work because no event.

The only workaround is to use a ListIconGadget() with only one column. It's working but visually speaking it's very ugly because I don't need a title and leaving it empty is ...

So any chance to have #PB_EventType_RightClick #PB_EventType_RightDoubleClick for the ListViewGadget() for the next version ?

Best regards
Guimauve

Re: Rightclick support for ListViewGadget

Posted: Sun Jan 20, 2013 2:34 pm
by CSHW89
+1 for RightClick and RightDoubleClick

@Guimauve: But in your case you can use #LVS_NOCOLUMNHEADER:

Code: Select all

If OpenWindow(0, 0, 0, 400, 300, "Test")
  ListIconGadget(0, 10, 10, 380, 280, "", 355, #LVS_NOCOLUMNHEADER)
  For i = 0 To 99
    AddGadgetItem(0, -1, Str(i+1)+". Element")
  Next
  
  Repeat: Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
br Kevin

Re: Rightclick support for ListViewGadget

Posted: Sun Jan 20, 2013 3:21 pm
by davido
+1 for RightClick and RightDoubleClick

Would be nice if it were in the spirit of PureBasic: cross-platform!

Re: Rightclick support for ListViewGadget

Posted: Sun Jan 20, 2013 4:17 pm
by Guimauve
CSHW89 wrote:+1 for RightClick and RightDoubleClick

@Guimauve: But in your case you can use #LVS_NOCOLUMNHEADER:
br Kevin
Only if I create a program for Windows. But it's not the case, I'm working on Linux.

I will have to check if it's possible to do something similar with GTK+

Best regards
Guimauve

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.