From: "Damian Yerrick" Newsgroups: comp.os.msdos.djgpp Subject: Re: How to Trap Double Mouse Click. Date: Mon, 4 Oct 1999 22:50:53 -0500 Organization: Rose-Hulman Institute of Technology Lines: 64 Message-ID: <7tbsn0$nmf$1@solomon.cs.rose-hulman.edu> References: <7tbjhr$vl0$1 AT nnrp1 DOT deja DOT com> NNTP-Posting-Host: yerricde.laptop.rose-hulman.edu X-Trace: solomon.cs.rose-hulman.edu 939095584 24271 137.112.205.146 (5 Oct 1999 03:53:04 GMT) X-Complaints-To: news AT cs DOT rose-hulman DOT edu NNTP-Posting-Date: 5 Oct 1999 03:53:04 GMT X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.00.2314.1300 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2314.1300 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com wrote in message news:7tbjhr$vl0$1 AT nnrp1 DOT deja DOT com... > Hello, > Can anyone tell me how to trap a double mouse click, left or right, > and maby middle. In general, the middle button is used to scroll the window; the user should be able to drag the view by holding the middle button and moving the mouse. > Oh, I'm using DJGPP, please help. I assume you're also using Allegro as your mouse and video library. If you are, the mouse buttons are stored in mouse_b You should already have called install_mouse() and install_timer() This code hasn't been tested; it's still open for input. >8 enum { BUTTON_1_MASK = 1, /* usually the left button */ BUTTON_2_MASK = 2, /* usually the right button */ BUTTON_CENTER_MASK = 4 /* not available on all mice */ }; #define DOUBLE_CLICK_TIME 27 /* times 1/70 second */ static int leftState, rightState, midState; static int leftTime, rightTime, midTime; int buttons, x; buttons = mouse_b; if((buttons & BUTTON_1_MASK) != leftState) { leftState = buttons & BUTTON_1_MASK; if(leftState = 1) { if((retrace_count - leftTime) < DOUBLE_CLICK_TIME) { HandleDoubleClick(); } else { HandleSingleClick(); } } leftTime = retrace_count; } >8 This code senses a double click message when the mouse button is pressed after having been released for less than one-third second. Damian Yerrick http://come.to/yerrick