Page 1 of 1

EventType () and ListViewGadget

Posted: Wed Nov 24, 2010 9:35 pm
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

Re: EventType () and ListViewGadget

Posted: Thu Nov 25, 2010 12:02 am
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

Re: EventType () and ListViewGadget

Posted: Thu Nov 25, 2010 1:49 am
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. ;)

Re: EventType () and ListViewGadget

Posted: Thu Nov 25, 2010 6:56 pm
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




@ + +

Re: EventType () and ListViewGadget

Posted: Fri Nov 26, 2010 4:24 am
by rsts