delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/05/03/03:20:37

From: James W Sager Iii <sager+@andrew.cmu.edu>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Hotspots and mouse.
Date: Sat, 2 May 1998 22:56:50 -0400
Organization: Junior, MCS Undeclared, Carnegie Mellon, Pittsburgh, PA
Lines: 30
Message-ID: <spGxnmK00WB=1335s0@andrew.cmu.edu>
References: <894150254 DOT 19440 DOT 0 DOT nnrp-04 DOT c1edaebc AT news DOT demon DOT co DOT uk>
NNTP-Posting-Host: andrew.cmu.edu
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Excerpts from netnews.comp.os.msdos.djgpp: 2-May-98 Hotspots and mouse.
by "Gillepileptic"@not-very 
> I hope someone can help me with Allegro:  I'm hoping to set up hotspots on a
> static screen (no animation at this stage) Pretty basic stuff, just point
> and click to call a function.
> I've already got the bitmap routines sorted, and I'll figure out the mouse
> stuff from the docs.
> I'd just like to know what's the most flexible and productive way of
> checking whether a mouse has clicked a 'hotspot'?  My program probably only
> needs "...if(((x>100) && (x<120)) &&... " etc, but this seems pretty
> hackish.

Thats exactly how you do it :)
Its quite easy.  The most important thing to remember is
to store
int x=mouse_x;
int y=mouse_y;
int b=mouse_b;

whenever you want to check a certain click.

Then do all your checking from these integers.
If you continually poll the mouse variables
you let yourself up to get weird unreproducable bugs.

Ie if mouse_x is in range(x>20 and x<40)
do some stuff and then
do something based on mouse_x.  It is wrong to
assume that mouse_x will still be in the range of 20,40

- Raw text -


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