delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/10/04/12:02:43

From: "Ross Boast" <Rossa AT btinternet DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Mouse Controlling with Allegro....
Date: 4 Oct 1997 15:17:38 GMT
Organization: BT Internet
Message-ID: <01bcd0d8$f5d324a0$5d3e63c3@rossa>
NNTP-Posting-Host: host5-99-62-93.btinternet.com
Lines: 39
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Hey!,
       I am working on a GUI atm, it's very simple i have drawn a box with
shadows and a caption using allegro. What i am having problems with is
this: i can't get a routine going which will work when the mouse is over
the button and the left mouse button is hit. I have tried storing the mouse
x and y of the button into a variable and then tried to match this with
mouse_x and mouse_y commands. Then said if the left button is pressed
(mouse_b & 1) quit the program.Instead of using aload of ifs i am now
trying it using switch...i can't get it to work at all. If i do get it to
work it will only quit when the mouse is at the top right corner and has
been pressed which could show a mistake on my part on how i am storing the
buttons x and y, so i will show this below :

    x = (mouse_x > 250) && (mouse_x < 320); // this will hold the exit
button mouse x 'hotspot'.
    y = (mouse_y > 400) && (mouse_y < 430); // this will hold the exit
button mouse y 'hotspot'.
    button = (mouse_b & 1);
    both = (mouse_x > 250) && (mouse_x < 320) && (mouse_y > 400) &&
(mouse_y < 430);

As you can see i have also tried to store both the x and y positions and
then match it up, i know this is probably not the way to do this, which is
why i am asking for help. Is there a problem with the way i am storing the
x and y positions or a problem with the way i am matching them up? is using
switch rather than ifs better in this case? please help me! its driving me
nuts!.If you could show me an example of the way you would store the x and
y position of the button then match them up to mouse_x and mouse_y, and
then if true exit, i would be really grateful! :).This is my first attempt
at GUI and mouse control, which might show ! , so be nice and understanding
please ;).

This is hard to put to you what i am trying to do, so tell me if you need
more of an explanation, i will try to make you understand !

-- 
Rossa :)
at
Rossa AT BTinternet DOT com

- Raw text -


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