Double Click & Single Click
Double Click & Single Click
-I have Window A
-It open over it Window B (and get A disabled)
-Window B is waiting for a double click on a iconlist
-When user double click, it closes Window B and enable again Window A
-The problem is that Window A get a SingleClick (when you double click, 3 events are generated, a Left+double+left)
How can I "delete" this last LeftClick event (or all events in the queue, I don't care) before returning to Window A?
-It open over it Window B (and get A disabled)
-Window B is waiting for a double click on a iconlist
-When user double click, it closes Window B and enable again Window A
-The problem is that Window A get a SingleClick (when you double click, 3 events are generated, a Left+double+left)
How can I "delete" this last LeftClick event (or all events in the queue, I don't care) before returning to Window A?
Last edited by AMpos on Fri Jul 31, 2020 11:19 am, edited 1 time in total.
- NicTheQuick
- Addict
- Posts: 1227
- Joined: Sun Jun 22, 2003 7:43 pm
- Location: Germany, Saarbrücken
- Contact:
Re: DOUBLE CLICK & SINGLE CLICK
You should consider showing us an example code which demonstrates that unexpected behaviour.
Furthermore, capital letters are understood as screams.
Furthermore, capital letters are understood as screams.
The english grammar is freeware, you can use it freely - But it's not Open Source, i.e. you can not change it or publish it in altered way.
- captain_skank
- Enthusiast
- Posts: 636
- Joined: Fri Oct 06, 2006 3:57 pm
- Location: England
Re: Double Click & Single Click
Have you got a single event handler loop for all windows.
Without code it's hard to help.
Without code it's hard to help.
Re: Double Click & Single Click
Ok, I will try to do a code, but... is it possible to clean the event queue, or a loop to wait until it is clear?
Something like
Something like
Code: Select all
REPEAT
event=eventwindow()
UNTIL event=0
- NicTheQuick
- Addict
- Posts: 1227
- Joined: Sun Jun 22, 2003 7:43 pm
- Location: Germany, Saarbrücken
- Contact:
Re: Double Click & Single Click
Are you serious? That's no example code that runs out of the box and shows the issue.
The english grammar is freeware, you can use it freely - But it's not Open Source, i.e. you can not change it or publish it in altered way.
Re: Double Click & Single Click
Of course it is not a sample code!!!!!
I am just asking this:
Is there a way to clean the (pb) event queue, or can a loop be created to wait until it is empty?
I am just asking this:
Is there a way to clean the (pb) event queue, or can a loop be created to wait until it is empty?
Re: Double Click & Single Click
Yes, like this:AMpos wrote: is it possible to clean the event queue, or a loop to wait until it is clear?
Code: Select all
While WindowEvent() : Wend
Re: Double Click & Single Click
Thank you, will try if it fixes my problem.BarryG wrote:Yes, like this:AMpos wrote: is it possible to clean the event queue, or a loop to wait until it is clear?
Code: Select all
While WindowEvent() : Wend
Re: Double Click & Single Click
The system always returns two pieces of information per event: the event itself and the window that generated the event.-I have Window A
-It open over it Window B (and get A disabled)
-Window B is waiting for a double click on a iconlist
-When user double click, it closes Window B and enable again Window A
-The problem is that Window A get a SingleClick (when you double click, 3 events are generated, a Left+double+left)
When working with a single window, only one piece of information is used, but when working with several windows, both pieces of information must be used.
Either before
Code: Select all
Select EventWindow()
Case #Win_A
Case #Win_B
Either in terms of events
Code: Select all
If EventType() = ... And EventWindow() =
Of course we can mix that up with the events common to all the windows.
Re: Double Click & Single Click
Here you have the Example Code.
If you DoubleClick on Window B, never should be a "Left Click" on Window A.
This code does not clear the queue. In fact, with this line disabled, WIndow A receives 2 single Clicks. Enable it, and it receives 1.
Code: Select all
OpenWindow(0,000,000,400,400,"Window A")
ListIconGadget(0,10,10,380,380,"TEST",100)
OpenWindow(1,40,40,320,320,"Window B")
ListIconGadget(1,10,10,300,300,"test 2",100)
DisableWindow(0,1)
Repeat
event=WaitWindowEvent()
Select EventGadget()
Case 1
Select EventType()
Case #PB_EventType_LeftDoubleClick
Debug "Click Twice at Window B"
CloseWindow(1)
DisableWindow(0,0)
SetActiveWindow(0)
Break
EndSelect
EndSelect
Until event=#PB_Event_CloseWindow
;While WindowEvent() : Wend
Repeat
event=WaitWindowEvent()
Select EventGadget()
Case 0
Select EventType()
Case #PB_EventType_LeftClick
Debug "Click Once at Window A"
EndSelect
EndSelect
Until event=#PB_Event_CloseWindow
Code: Select all
While WindowEvent() : Wend
Re: Double Click & Single Click
I ahve made another version, checking if the event was in Window A, and it does not work, also:
Code: Select all
OpenWindow(0,000,000,400,400,"Window A")
ListIconGadget(0,10,10,380,380,"TEST",100)
OpenWindow(1,40,40,320,320,"Window B")
ListIconGadget(1,10,10,300,300,"test 2",100)
DisableWindow(0,1)
Repeat
event=WaitWindowEvent()
Select EventGadget()
Case 1
Select EventType()
Case #PB_EventType_LeftDoubleClick
Debug "Click Twice at Window B"
CloseWindow(1)
DisableWindow(0,0)
SetActiveWindow(0)
Break
EndSelect
EndSelect
Until event=#PB_Event_CloseWindow
Repeat
event=WaitWindowEvent()
Select EventGadget()
Case 0
If EventType()=#PB_EventType_LeftClick And EventWindow()=0
Debug "Click Once at Window A"
EndIf
EndSelect
Until event=#PB_Event_CloseWindow
Re: Double Click & Single Click
[Removed, mistake on my part]
Last edited by BarryG on Sat Aug 01, 2020 8:35 am, edited 1 time in total.
Re: Double Click & Single Click
Your evaluation of the events is not complete.
Always use only one EventLoop with WaitWindowEvent(). Otherwise you get confused and you wonder why one event does not arrive.
Always use only one EventLoop with WaitWindowEvent(). Otherwise you get confused and you wonder why one event does not arrive.
Code: Select all
Procedure Open1()
If OpenWindow(0,000,000,400,400,"window a", #PB_Window_SystemMenu)
ListIconGadget(0,10,10,380,380,"test",100)
ProcedureReturn #True
Else
ProcedureReturn #False
EndIf
EndProcedure
Procedure Open2()
If OpenWindow(1,40,40,320,320,"window b", #PB_Window_SystemMenu, WindowID(0))
ListIconGadget(1,10,10,300,300,"test 2",100)
ProcedureReturn #True
Else
ProcedureReturn #False
EndIf
EndProcedure
Procedure MainLoop()
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Select EventWindow()
Case 0
Break ; leave the event loop
Case 1
DisableWindow(0,0)
SetActiveWindow(0)
CloseWindow(1)
EndSelect
Case #PB_Event_Menu
Select EventMenu()
;
EndSelect
Case #PB_Event_Gadget
Select EventGadget()
Case 0
Select EventType()
Case #PB_EventType_LeftDoubleClick
Debug "click twice at list a"
If Open2()
DisableWindow(0, 1)
EndIf
EndSelect
Case 1
Select EventType()
Case #PB_EventType_LeftDoubleClick
Debug "click twice at list b"
EndSelect
EndSelect
EndSelect
ForEver
EndProcedure
If Open1()
If Open2()
DisableWindow(0,1)
EndIf
MainLoop()
EndIf
End
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
Re: Double Click & Single Click
It doesnt work. Window B has to be closed after a double click. And Window A only has to respond to Sinlge Left Click.mk-soft wrote:Your evaluation of the events is not complete.
Always use only one EventLoop with WaitWindowEvent(). Otherwise you get confused and you wonder why one event does not arrive.
Code: Select all
...
I tryied to add "close window..." part to the LeftDoubleClick and change the first Left to DoubleLeft and it keeps closing and opening Window B, and detecting also a LeftClick on Window A.
Re: Double Click & Single Click
[Removed, mistake on my part]
Last edited by BarryG on Sat Aug 01, 2020 8:35 am, edited 1 time in total.