BBC BASIC for Windows
Programming >> BBC BASIC language >> Using the Mouse http://bb4w.conforums.com/index.cgi?board=language&action=display&num=1444207868 Using the Mouse
Post by basscott on Oct 7th, 2015, 08:51am
I am new to BBC Basic and have an issue using the mouse.
I use the following to get the co-ordinates when I click the mouse and this works OK: -
REPEAT MOUSE X,Y,BUTTON% UNTIL BUTTON%
I then use X and Y to determine where in the window the mouse is pointing to in order to carry out some simple code - I then go to another part of the program where I repeat the above code to get a 2nd location when I click the mouse.
The issue I have is that the values of X and Y remain the same as the first click and don't seem to get overwritten by the details from the 2nd click; in fact the program doesn't seem to wait for the mouse to be clicked on the 2nd occasion.
I'm probably misunderstanding the way that this functionality works - any help please ?
Re: Using the Mouse
Post by basscott on Oct 7th, 2015, 08:53am
that should be : -
UNTIL BUTTON%<>0
Re: Using the Mouse
Post by DDRM on Oct 7th, 2015, 09:34am
Hi Basscott,
I think the problem is that there are usually a stream of responses sitting in the mouse buffer (usually about half a dozen or so from a single click). I usually end any mouse-handling routine with... Code:
REPEAT MOUSE x%,y%,z%
UNTIL z%=0
...which empties the buffer. Hope that helps!
D
Re: Using the Mouse
Post by number6 on Oct 7th, 2015, 11:07am
Hi basscott Thanks for asking that particular question and thanks also to DDRM for his reply. I had a similar problem and DDRM's solution is exactly what was needed.! Re: Using the Mouse
Post by basscott on Oct 7th, 2015, 2:49pm