Mail Archives: djgpp/1997/10/25/01:32:12
On Fri, 24 Oct 97 21:53:25 GMT in comp.os.msdos.djgpp Gautam N. Lad (gautam AT interlog DOT com) wrote:
: Hi,
: I have a problem, with something like this:
: for(;;)
: {
: if(mouse_b & 1) // Left mouse button pressed
: {
: mouse_b=0; // clear the mouse buttons. Does this work?
Horrible, horrible; probably not. I'd expect the next mouse callback (e.g.
when the mouse moves a bit) to poll the buttons again, and update mouse_b.
You really shouldn't write to mouse_b.
: for(;;)
: {
: if(mouse_b & 1) return; // If mouse is pressed for 2nd time, return.
: } // End of 2nd forever loop
: } // End of first if(mouse_b & 1) loop
: } // End of 1st forever loop
: What is happening? I don't know what to do. I'm trying something like a 2D
: Draw program, where if I choose to draw a circle, I select a point on the screen
: (first time button is pressed), then I move the mouse around (as I do, the radius
: changes), and then I click one last time to make the circle radius permanent.
Instead of setting mouse_b=0, try: while (mouse_b & 1); instead. This will
wait for the user to release the button. Then poll the mouse, draw circles,
etc. until (mouse_b & 1) is set again. You'll probably want to wait for the
button to be released again afterwards, because otherwise you'll probably
start drawing another circle immediately.
--
Regards,
george DOT foot AT merton DOT oxford DOT ac DOT uk
- Raw text -