delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/10/25/01:32:12

From: mert0407 AT sable DOT ox DOT ac DOT uk (George Foot)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Allegro 2.2 : Trouble with Mouse (sorta)
Date: 24 Oct 1997 23:13:40 GMT
Organization: Oxford University, England
Lines: 37
Message-ID: <62ra34$78h$2@news.ox.ac.uk>
References: <62r4st$9sa$1 AT news DOT interlog DOT com>
NNTP-Posting-Host: sable.ox.ac.uk
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019