From: George Foot Newsgroups: comp.os.msdos.djgpp Subject: Re: Area of square problem, different. Date: 12 Jun 1998 03:30:07 GMT Organization: Oxford University, England Lines: 44 Message-ID: <6lq7bv$f0m$1@news.ox.ac.uk> References: <35806450 DOT B3F694CD AT netrover DOT com> NNTP-Posting-Host: sable.ox.ac.uk To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk On Thu, 11 Jun 1998 19:12:17 -0400 in comp.os.msdos.djgpp Nicolas Blais wrote: : The bit of code below seams to work partially or actually more than I : expect, because when I click on the rectangle, it gives me millions : (seriously) of the "Yep" string, but I only want one. In that case, when the user presses the button, print the string and then wait for them to release the button. This makes your program block, which is slightly undesirable, but is probably sufficient for what you want to do. : Also, sometimes, : it just doesn't print the "Yep". Can this be fixed? Perhaps it's writing the string off the screen. I presume you're using 800x600 mode; when you call textout you specify the top-left coordinate. In your system, the X coordinate could be the far right hand edge of the screen (in which case the text will be drawn off the edge of the screen) and the Y coordinate could be the very bottom of the screen, with a similar effect (or rather, non-effect). : if (mouse_b == 1) You're testing here for the left button to be pressed and all other buttons to be unpressed; if you just want to check the left button, use the bitwise AND operator: if (mouse_b & 1) /* test left mouse button */ : { : show_mouse(NULL); : textout(screen,font,"Yep",random() % 800,random() % : 600,RGB(0,255,0)); while (mouse_b & 1); /* wait for button to be released */ : show_mouse(screen); : } -- george DOT foot AT merton DOT oxford DOT ac DOT uk xu do tavla fo la lojban -- http://xiron.pc.helsinki.fi/lojban/lojban.html