It is currently Thu Oct 22, 2020 6:48 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 25 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Double Click & Single Click
PostPosted: Fri Jul 31, 2020 9:19 am 
Offline
Enthusiast
Enthusiast

Joined: Fri Jun 05, 2020 12:47 am
Posts: 123
-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?


Last edited by AMpos on Fri Jul 31, 2020 11:19 am, edited 1 time in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: DOUBLE CLICK & SINGLE CLICK
PostPosted: Fri Jul 31, 2020 9:59 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sun Jun 22, 2003 7:43 pm
Posts: 603
Location: Germany, Saarbrücken
You should consider showing us an example code which demonstrates that unexpected behaviour.

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.


Top
 Profile  
Reply with quote  
 Post subject: Re: Double Click & Single Click
PostPosted: Fri Jul 31, 2020 11:39 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Fri Oct 06, 2006 3:57 pm
Posts: 570
Location: England
Have you got a single event handler loop for all windows.

Without code it's hard to help.


Top
 Profile  
Reply with quote  
 Post subject: Re: Double Click & Single Click
PostPosted: Fri Jul 31, 2020 11:41 am 
Offline
Enthusiast
Enthusiast

Joined: Fri Jun 05, 2020 12:47 am
Posts: 123
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

Code:
REPEAT
 event=eventwindow()
UNTIL event=0


Top
 Profile  
Reply with quote  
 Post subject: Re: Double Click & Single Click
PostPosted: Fri Jul 31, 2020 11:43 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sun Jun 22, 2003 7:43 pm
Posts: 603
Location: Germany, Saarbrücken
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.


Top
 Profile  
Reply with quote  
 Post subject: Re: Double Click & Single Click
PostPosted: Fri Jul 31, 2020 11:49 am 
Offline
Enthusiast
Enthusiast

Joined: Fri Jun 05, 2020 12:47 am
Posts: 123
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?


Top
 Profile  
Reply with quote  
 Post subject: Re: Double Click & Single Click
PostPosted: Fri Jul 31, 2020 12:29 pm 
Offline
Addict
Addict

Joined: Thu Apr 18, 2019 8:17 am
Posts: 1034
AMpos wrote:
is it possible to clean the event queue, or a loop to wait until it is clear?

Yes, like this:

Code:
While WindowEvent() : Wend


Top
 Profile  
Reply with quote  
 Post subject: Re: Double Click & Single Click
PostPosted: Fri Jul 31, 2020 12:31 pm 
Offline
Enthusiast
Enthusiast

Joined: Fri Jun 05, 2020 12:47 am
Posts: 123
BarryG wrote:
AMpos wrote:
is it possible to clean the event queue, or a loop to wait until it is clear?

Yes, like this:

Code:
While WindowEvent() : Wend


Thank you, will try if it fixes my problem.


Top
 Profile  
Reply with quote  
 Post subject: Re: Double Click & Single Click
PostPosted: Fri Jul 31, 2020 1:40 pm 
Offline
Addict
Addict

Joined: Sat Feb 08, 2014 3:26 pm
Posts: 942
Quote:
-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)
The system always returns two pieces of information per event: the event itself and the window that generated the event.
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 EventWindow()
    Case #Win_A
    Case #Win_B

Either in terms of events
Code:
If EventType() = ... And EventWindow() =       

This way the events in one window do not influence the other windows. No need to empty the event queue.

Of course we can mix that up with the events common to all the windows.

:wink:

_________________
(English is not my native language, I use an online translator.)


Top
 Profile  
Reply with quote  
 Post subject: Re: Double Click & Single Click
PostPosted: Fri Jul 31, 2020 11:07 pm 
Offline
Enthusiast
Enthusiast

Joined: Fri Jun 05, 2020 12:47 am
Posts: 123
Here you have the Example Code.

Code:
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


If you DoubleClick on Window B, never should be a "Left Click" on Window A.

Code:
While WindowEvent() : Wend


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.


Top
 Profile  
Reply with quote  
 Post subject: Re: Double Click & Single Click
PostPosted: Fri Jul 31, 2020 11:12 pm 
Offline
Enthusiast
Enthusiast

Joined: Fri Jun 05, 2020 12:47 am
Posts: 123
I ahve made another version, checking if the event was in Window A, and it does not work, also:

Code:
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


Top
 Profile  
Reply with quote  
 Post subject: Re: Double Click & Single Click
PostPosted: Sat Aug 01, 2020 12:26 am 
Offline
Addict
Addict

Joined: Thu Apr 18, 2019 8:17 am
Posts: 1034
[Removed, mistake on my part]


Last edited by BarryG on Sat Aug 01, 2020 8:35 am, edited 1 time in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: Double Click & Single Click
PostPosted: Sat Aug 01, 2020 12:55 am 
Offline
Addict
Addict
User avatar

Joined: Fri May 12, 2006 6:51 pm
Posts: 2681
Location: Germany
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:
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 / OOP-BaseClassDispatch / EventDesigner V3
PB v3.30 / v5.70 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace


Top
 Profile  
Reply with quote  
 Post subject: Re: Double Click & Single Click
PostPosted: Sat Aug 01, 2020 7:05 am 
Offline
Enthusiast
Enthusiast

Joined: Fri Jun 05, 2020 12:47 am
Posts: 123
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:
...



It doesnt work. Window B has to be closed after a double click. And Window A only has to respond to Sinlge Left Click.

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.


Top
 Profile  
Reply with quote  
 Post subject: Re: Double Click & Single Click
PostPosted: Sat Aug 01, 2020 7:09 am 
Offline
Addict
Addict

Joined: Thu Apr 18, 2019 8:17 am
Posts: 1034
[Removed, mistake on my part]


Last edited by BarryG on Sat Aug 01, 2020 8:35 am, edited 1 time in total.

Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 25 posts ]  Go to page 1, 2  Next

All times are UTC + 1 hour


Who is online

Users browsing this forum: marc_256, STARGÅTE and 44 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye