[Gambas-user] WAIT in sub reverses number

nando nando_f at ...951...
Fri Jun 5 07:48:50 CEST 2009


I had a similar thing happen a while ago.
It is caused because of something like this:

When a key event happens, there is a key value associated with the event.
BUT the WAIT allows the next key event to happen before the first key event
actually finishes and exits the SUB for that key value
So
the next key event, which happens inside the first key event is detected
inside while the WAIT is being performed which results in a second key event to
fire ... all happening before the original first key event did not actually 
finish yet.

It turns out that all the keys received into the system have key events
associated with them, and they are recursively deep due to the WAIT.
Then, when there are no more keys, the last most WAIT returns and
that key event finishes
and that is the first key you see (which is the last one typed)
..and all the events end, producing key strokes in the reverse order.

This is also completely possible in VB


---------- Original Message -----------
From: Doriano Blengino <doriano.blengino at ...1909...>
To: mailing list for gambas users <gambas-user at lists.sourceforge.net>
Sent: Fri, 05 Jun 2009 07:21:16 +0200
Subject: Re: [Gambas-user] WAIT in sub reverses number

> Ken Thornton-Smith ha scritto:
> > I'm  entering numbers from an RFID tag reader into a text box.
> > A keypress event here opens another text box and moves cursor focus.
> >
> > Obviously, the first character opens the second textbox and the rather  
> > slow usb puts the remaining characters in the second box.
> > Being lazy, instead of looking for the complete string, I put in WAIT  
> > 0.5.
> >
> > This enters the correct string but the string is now in the first box  
> > in reverse.
> > Keyboard entry has a similar effect.
> >
> > Gambas 2, no code necessary, works on two machines in any text box.
> >
> > Any theories?
> >   
> I am not sure to well understand, but it seems that, for every 
> character, the first textbox looses focus and gains it again. This moves 
> the text cursor at the beginning, so arriving characters are stored in 
> reverse order. Is it this that happens?
> 
> You can put PRINT statements in the event handlers to trace what 
> controls take focus (and hence, the arriving characters). You can use 
> Application.ActiveControl to know, at any time, what control has the focus.
> 
> Anyway, try to use a single-shot timer instead of a WAIT: it could 
> behave differently.
> 
> Hope this helps,
> 
> -- 
> Doriano Blengino
> 
> "Listen twice before you speak.
> This is why we have two ears, but only one mouth."
> 
> ------------------------------------------------------------------------------
> OpenSolaris 2009.06 is a cutting edge operating system for enterprises 
> looking to deploy the next generation of Solaris that includes the latest 
> innovations from Sun and the OpenSource community. Download a copy and 
> enjoy capabilities such as Networking, Storage and Virtualization. 
> Go to: http://p.sf.net/sfu/opensolaris-get
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
------- End of Original Message -------





More information about the User mailing list