[SOLVED] How to get the right click event from a listview?
[SOLVED] How to get the right click event from a listview?
I have searched this forum for the captioned query.
Somebody said that there is a Window API for it.
Could anybody help me with example codes?
Somebody said that there is a Window API for it.
Could anybody help me with example codes?
Last edited by avatar on Thu Apr 22, 2010 4:20 am, edited 1 time in total.
Re: How to get the right click event from a listview?
What about...

Code: Select all
Select WaitWindowEvent()
Case #PB_Event_Gadget
Select EventGadget()
Case #ListView
If EventType() = #PB_EventType_RightClick
DisplayPopupMenu(#ListViewMenu, WindowID(#Window))
EndIf
;[...]If any of you native English speakers have any suggestions for the above text, please let me know (via PM). Thanks!
Re: How to get the right click event from a listview?
Already tried
and
the PB manual says not support right-click in ListView
i am now considering recoding to change to ListIcon
and
the PB manual says not support right-click in ListView
i am now considering recoding to change to ListIcon
Re: How to get the right click event from a listview?
Ah sorry I missed that.
Anyway you can make a ListIconGadget() look and behave like a ListViewGadget() so it shoulfn't be a problem.
Anyway you can make a ListIconGadget() look and behave like a ListViewGadget() so it shoulfn't be a problem.
If any of you native English speakers have any suggestions for the above text, please let me know (via PM). Thanks!
Re: How to get the right click event from a listview?
Code: Select all
Procedure WinCB(hWnd, uMsg, wParam, lParam)
Protected result = #PB_ProcessPureBasicEvents
Select uMsg
Case #WM_CONTEXTMENU
If GetActiveGadget() = 0
Debug "Contextmenu on ListView"
EndIf
EndSelect
ProcedureReturn result
EndProcedure
If OpenWindow(0, 0, 0, 270, 140, "ListViewGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ListViewGadget(0, 10, 10, 250, 120)
For a = 1 To 12
AddGadgetItem (0, -1, "Item " + Str(a) + " of the Listview")
Next
SetGadgetState(0, 9)
SetWindowCallback(@WinCB())
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
Re: How to get the right click event from a listview?
Very helpful ts-soft! 
I was trying callback and failed on Case #WM_RBUTTONDOWN ?
srod's EasyVent works also. But, this is sufficient to allow a popup menu or some such on a simple ListView.
I was trying callback and failed on Case #WM_RBUTTONDOWN ?
srod's EasyVent works also. But, this is sufficient to allow a popup menu or some such on a simple ListView.
Last edited by skywalk on Sun Nov 25, 2012 8:55 pm, edited 1 time in total.
Re: How to get the right click event from a listview?
Is only useful on listview and editorgadget.
Re: How to get the right click event from a listview?
Does this work on all gadgets? I don't know:
Code: Select all
Procedure RightClick(#Window, #Gadget, Event)
If Event = #WM_RBUTTONDOWN
If WindowMouseX(#Window) > GadgetX(#Gadget) And WindowMouseX(#Window) < GadgetX(#Gadget) + GadgetWidth(#Gadget)
If WindowMouseY(#Window) > GadgetY(#Gadget) And WindowMouseY(#Window) < GadgetY(#Gadget) + GadgetHeight(#Gadget)
; [Bla bla bla...} or
; ProcedureReturn 1
EndIf
EndIf
EndIf
EndProcedure
#MainWin = 0
#ListViewG = 0
OpenWindow(#MainWin, #PB_Ignore, #PB_Ignore, 200, 200, "Test", #PB_Window_ScreenCentered)
ListViewGadget(#ListView, 5, 5, 100, 100)
Repeat
Evt = WaitWindowEvent()
RightClick(#MainWin, #ListViewG, Evt)
Until Evt = #PB_Event_CloseWindow
Re: How to get the right click event from a listview?
Thank you all for the input.
Re: [SOLVED] How to get the right click event from a listvie
Unfortunately ts-soft's example contains a bug: If your first action is a right click, this
right click will not be detected. Only after a first left mouse click all following right clicks
are reliably detected. In order to solve this problem you should compare the wParam
with the handle of the ListViewGadget to make sure that the right click occured inside the
ListViewGadget:
right click will not be detected. Only after a first left mouse click all following right clicks
are reliably detected. In order to solve this problem you should compare the wParam
with the handle of the ListViewGadget to make sure that the right click occured inside the
ListViewGadget:
Code: Select all
Procedure WinCB(hWnd, uMsg, wParam, lParam)
Protected result = #PB_ProcessPureBasicEvents
Select uMsg
Case #WM_CONTEXTMENU
If wParam = GadgetID(0)
Debug "Contextmenu on ListView"
EndIf
EndSelect
ProcedureReturn result
EndProcedure
If OpenWindow(0, 0, 0, 270, 140, "ListViewGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ListViewGadget(0, 10, 10, 250, 120)
For a = 1 To 12
AddGadgetItem (0, -1, "Item " + Str(a) + " of the Listview")
Next
SetGadgetState(0, 9)
SetWindowCallback(@WinCB())
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIfRe: [SOLVED] How to get the right click event from a listvie
In wParam is the hwnd, thx.
I have tested with lParam
I have tested with lParam


