Rightclick support for ListViewGadget

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
Shardik
Addict
Addict
Posts: 2067
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: 2148
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