EventType () and ListViewGadget

Just starting out? Need help? Post your questions and find answers here.
User avatar
venom27
User
User
Posts: 10
Joined: Mon Sep 14, 2009 5:30 pm
Location: . <------ ici
Contact:

EventType () and ListViewGadget

Post by venom27 »

Hello, sorry I do not speak English, I translated via google.

that's when I made a right click via EventType () in a ListIconGadget it works.

but when I did a right click via EventType () in a ListViewGadget this does not work.

you know why? I made a mistake?

Here is a sample code:

Code: Select all

;- Window Constants
Enumeration
  #Window_0
EndEnumeration

;- Gadget Constants
Enumeration
  #Listview_0
  #ListIcon_0
EndEnumeration

  If OpenWindow(#Window_0, 0, 0, 320, 150, "New window",  #PB_Window_SystemMenu | #PB_Window_TitleBar | #PB_Window_ScreenCentered )
      ListViewGadget(#Listview_0, 10, 10, 140, 130)
      ListIconGadget(#ListIcon_0, 170, 10, 140, 130, "Column0", 100)
  EndIf
  
  Repeat
   EventID = WaitWindowEvent()
    If EventID = #PB_Event_Gadget
      Select EventGadget()
        
        Case #Listview_0
          Select EventType()
           Case #PB_EventType_RightClick
            Beep_(1000, 500)
          EndSelect
        
        Case #ListIcon_0
          Select EventType()
           Case #PB_EventType_RightClick
            Beep_(1000, 500)
          EndSelect

      EndSelect
    EndIf
  Until EventID = #PB_Event_CloseWindow
thank
Windows 10 x64, PureBasic 5.71 Beta 1 x86 & x64
User avatar
Vera
Addict
Addict
Posts: 858
Joined: Tue Aug 11, 2009 1:56 pm
Location: Essen (Germany)

Re: EventType () and ListViewGadget

Post by Vera »

Hello venom27,
venom27 wrote:when I did a right click via EventType () in a ListViewGadget this does not work.
yes that is ok :)

Please see the help file:
ListIconGadget()
ListIconGadget() wrote:The following events are supported through EventType():
#PB_EventType_LeftClick: left click on an item, or a checkbox was checked/unchecked
#PB_EventType_LeftDoubleClick
#PB_EventType_RightClick
#PB_EventType_RightDoubleClick
#PB_EventType_Change: the current item changed
#PB_EventType_DragStart: the user tried to start a Drag & Drop operation.
ListViewGadget()
ListViewGadget() wrote:The following events are supported through EventType():
#PB_EventType_LeftClick
#PB_EventType_LeftDoubleClick
and have a look a this example.

Code: Select all

Enumeration
  #Window_0
EndEnumeration

Enumeration
  #Listview_0
  #ListIcon_0
EndEnumeration

If OpenWindow(#Window_0, 0, 0, 320, 150, "ListView",  #PB_Window_SystemMenu | #PB_Window_TitleBar | #PB_Window_ScreenCentered )
  ListViewGadget(#Listview_0, 10, 10, 140, 130)
  ListIconGadget(#ListIcon_0, 170, 10, 140, 130, "ListIcon", 100)
EndIf

Repeat
  EventID = WaitWindowEvent()
  If EventID = #PB_Event_Gadget
    Select EventGadget()
        
      Case #Listview_0
        Debug "List View: " +Str(EventType())
        Select EventType()
          Case #PB_EventType_RightClick
        EndSelect
        
      Case #ListIcon_0
        Debug "List Icon: " +Str(EventType())
        Select EventType()
          Case #PB_EventType_RightClick
        EndSelect
        
    EndSelect
  EndIf
Until EventID = #PB_Event_CloseWindow 
I hope this helps and you're welcome to ask any time :)

But if you are not sure if something is a bug then please ask in another forum first like e.g.: Coding Questions.

greetings ~ Vera
PureLust
Enthusiast
Enthusiast
Posts: 477
Joined: Mon Apr 16, 2007 3:57 am
Location: Germany, NRW

Re: EventType () and ListViewGadget

Post by PureLust »

Hi venom27,

as Vera already said, PureBasic doesn't support right-clicks for a ListViewGadget() (for whatever reason Image ).
But you can still recognize it on your own.

The following code will show you how to get noticed if one clicks the RMB (RightMouseButton) on the ListViewGadget().

(This example is for Windows-only !!! If you need it for Linux or Mac OS-X, I think there is a solution for them as well somewhere in the forum.)

Code: Select all

Enumeration
	#Window_0
EndEnumeration

Enumeration
	#Listview_0
	#ListIcon_0
EndEnumeration

Define CursorPos.Point		; ----- you need this Variable for the API-Call: GetCursorPos_(@CursorPos)

If OpenWindow(#Window_0, 0, 0, 320, 150, "ListView",  #PB_Window_SystemMenu | #PB_Window_TitleBar | #PB_Window_ScreenCentered )
	ListViewGadget(#Listview_0, 10, 10, 140, 130)
	ListIconGadget(#ListIcon_0, 170, 10, 140, 130, "ListIcon", 100)
EndIf

Repeat
	EventID = WaitWindowEvent()
	If EventID = #PB_Event_Gadget
		Select EventGadget()
				
			Case #Listview_0
				Debug "List View: " +Str(EventType())
				Select EventType()
					Case #PB_EventType_RightClick
				EndSelect
				
			Case #ListIcon_0
				Debug "List Icon: " +Str(EventType())
				Select EventType()
					Case #PB_EventType_RightClick
				EndSelect
				
		EndSelect
		
	Else		; If PB does not give you back the right Gadget for an Event, try to find it on your own
		
		Select EventID
				
			Case #WM_RBUTTONDOWN																	; Event "#WM_RBUTTONDOWN" = pressing the RMB
				
				GetCursorPos_(@CursorPos)														; reading actual Cursor-Position
				If WindowFromPoint_(PeekQ(@CursorPos)) = GadgetID(#Listview_0)		; check, if the Gadget underneath the cursor is the ListViewGadget you're looking for
					Debug "RMB clicked on ListView-Gadget"
				EndIf
				
			Case #WM_RBUTTONUP																	; Event "#WM_RBUTTONUP" = releasing the RMB
				
				GetCursorPos_(@CursorPos)														; reading actual Cursor-Position
				If WindowFromPoint_(PeekQ(@CursorPos)) = GadgetID(#Listview_0)		; check, if the Gadget underneath the cursor is the ListViewGadget you're looking for
					Debug "RMB released from ListView-Gadget"
				EndIf
				
		EndSelect			
	EndIf
Until EventID = #PB_Event_CloseWindow
Greetings, PL.

PS:
venom27 wrote:Hello, sorry I do not speak English, I translated via google.
If you don't speak English, it would be helpful, if you note your Country or your native language in your user-profile. ;)
[Dynamic-Dialogs] - create complex GUIs the easy way
[DeFlicker] - easily deflicker your resizeable Windows
[WinFX] - Window Effects (incl. 'click-through' Window)
User avatar
venom27
User
User
Posts: 10
Joined: Mon Sep 14, 2009 5:30 pm
Location: . <------ ici
Contact:

Re: EventType () and ListViewGadget

Post by venom27 »

Good evening, Thanks for your replies at first, I tried to translate the most of your topic.

I'm French and I use purebasic for several years, only I never go here. : (

Regarding my problem, I must misread the French documentation because for me it was compatible. : S

PureLust thank you for your code, I'll consider that.
ah you through the API's :wink:

I apologize for the inconvenience. Soon
Venom




@ + +
Windows 10 x64, PureBasic 5.71 Beta 1 x86 & x64
rsts
Addict
Addict
Posts: 2736
Joined: Wed Aug 24, 2005 8:39 am
Location: Southwest OH - USA

Re: EventType () and ListViewGadget

Post by rsts »

Post Reply