Mail Archives: djgpp/1998/06/12/01:00:30
On Thu, 11 Jun 1998 19:12:17 -0400 in comp.os.msdos.djgpp Nicolas
Blais <eletech AT netrover DOT com> 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
- Raw text -