Rightclick support for ListViewGadget

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
kenmo
Addict
Addict
Posts: 2033
Joined: Tue Dec 23, 2003 3:54 am

Rightclick support for ListViewGadget

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

Re: Rightclick support for ListViewGadget

Post by WilliamL »

Would like to ask again to add the rightclick for the ListView gadget.
MacBook Pro-M1 (2021), Sequoia 15.4, PB 6.20
Little John
Addict
Addict
Posts: 4777
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: Rightclick support for ListViewGadget

Post by Little John »

I would appreciate that, too.

Regards, Little John
User avatar
Guimauve
Enthusiast
Enthusiast
Posts: 742
Joined: Wed Oct 22, 2003 2:51 am
Location: Canada

Re: Rightclick support for ListViewGadget

Post 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
Dear Optimist, Pessimist,
and Realist,

While you guys were
busy arguing about the
glass of water, I DRANK IT !

Sincerely,
the Opportunist
CSHW89
User
User
Posts: 30
Joined: Thu Sep 09, 2010 2:47 pm

Re: Rightclick support for ListViewGadget

Post 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
Image Image Image
davido
Addict
Addict
Posts: 1890
Joined: Fri Nov 09, 2012 11:04 pm
Location: Uttoxeter, UK

Re: Rightclick support for ListViewGadget

Post by davido »

+1 for RightClick and RightDoubleClick

Would be nice if it were in the spirit of PureBasic: cross-platform!
DE AA EB
User avatar
Guimauve
Enthusiast
Enthusiast
Posts: 742
Joined: Wed Oct 22, 2003 2:51 am
Location: Canada

Re: Rightclick support for ListViewGadget

Post 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
Dear Optimist, Pessimist,
and Realist,

While you guys were
busy arguing about the
glass of water, I DRANK IT !

Sincerely,
the Opportunist
User avatar
Shardik
Addict
Addict
Posts: 2058
Joined: Thu Apr 21, 2005 2:38 pm
Location: Germany

Re: Rightclick support for ListViewGadget

Post 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
User avatar
Andre
PureBasic Team
PureBasic Team
Posts: 2137
Joined: Fri Apr 25, 2003 6:14 pm
Location: Germany (Saxony, Deutscheinsiedel)
Contact:

Re: Rightclick support for ListViewGadget

Post by Andre »

+1 for rightclick support at ListViewGadget and other eventtypes, already supported by ListIconGadget.
Bye,
...André
(PureBasicTeam::Docs & Support - PureArea.net | Order:: PureBasic | PureVisionXP)
davido
Addict
Addict
Posts: 1890
Joined: Fri Nov 09, 2012 11:04 pm
Location: Uttoxeter, UK

Re: Rightclick support for ListViewGadget

Post by davido »

+1 for rightclick support at ListViewGadget and other eventtypes, already supported by ListIconGadget.
DE AA EB
Ulix
User
User
Posts: 48
Joined: Wed Jan 23, 2008 12:45 pm
Location: France, Montpellier

Re: Rightclick support for ListViewGadget

Post by Ulix »

+1 for RightClick and RightDoubleClick and cross-platform !
Joris
Addict
Addict
Posts: 890
Joined: Fri Oct 16, 2009 10:12 am
Location: BE

Re: Rightclick support for ListViewGadget

Post 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).
Yeah I know, but keep in mind ... Leonardo da Vinci was also an autodidact.
Polo
Addict
Addict
Posts: 2422
Joined: Tue May 06, 2003 5:07 pm
Location: UK

Re: Rightclick support for ListViewGadget

Post by Polo »

+1, been limited by this before!
User avatar
charvista
Addict
Addict
Posts: 949
Joined: Tue Sep 23, 2008 11:38 pm
Location: Belgium

Re: Rightclick support for ListViewGadget

Post by charvista »

+1 RightClick

But not sure for what a DoubleRightClick might be useful... But implementation is OK.
- Windows 11 Home 64-bit
- PureBasic 6.10 LTS (x64)
- 64 Gb RAM
- 13th Gen Intel(R) Core(TM) i9-13900K 3.00 GHz
- 5K monitor with DPI @ 200%
Post Reply