Subject:     Mouse Button Handler - CODE
      Date:     19 Jun 1998 10:17:32 GMT
      From:     "Elim Garak" <laf@coventry.ac.uk>
 Organization:  BT Internet
 Newsgroups:    comp.lang.pascal.borland
 

Here is a procedure I wrote a little while ago and now can't live without,
hope its of some use.

Const
  Mouse_Delay = 3;

Var

xm,ym:WORD {mouse x and y}
buttons,oldbuttons,veryoldbuttons:WORD; {Mouse button Handlers}
ButtonPress:boolean;
ButtonDepress:Boolean;
Mouse_Delay:Integer;
 
 

PROCEDURE Mouse_Status;
BEGIN

ButtonDepress:=FALSE;

if mousedelay>mouse_delay then
 BEGIN
  Mousedelay:=0;

   if (oldbuttons = buttons)  and (buttons>0) then
    BEGIN
      buttonpress:=true;
      buttons := oldbuttons;
      veryoldbuttons := buttons;
    END ELSE
    BEGIN
     if buttonpress= true then buttondepress:=true;
     buttonpress:=FALSE;
     buttons:=oldbuttons;
    END;
 END;
inc(mousedelay);
END;

BEGIN
getmouseposition(xm,ym,oldbuttons);
Mouse_Status;
{ It's important that whatever mouse handler you use the value
  ordinarily reported for the mouse button is placed within
  the varible oldbuttons.  BUT the code from now on will still work
   on the variable buttons, so-forth)

IF (Buttonpress=TRUE) AND(buttons=1) Then dosomething;
 

END.

USER NOTES:

When checking for a depress on a specific button you should look at
veryoldbuttons for the button that has been clicked

{ IE to right-click on a button }

IF (buttondepress=true) and (veryoldbuttons=2) and (mouse in range) then
 dowhatwever;
 

--
Said the spider, "My pretty little tasty thing, you think you will go to
hell?  Whatever makes you think your alive?"



http://www.oocities.org/SiliconValley/2926/tp.html

 This page hosted by  Get your own Free Homepage