Solved

Trapping double-click before mouse down event

Posted on 1998-10-13
9
1,545 Views
Last Modified: 2010-04-06
Hi

I am wondering if it is possible to delay the processing of the MouseDown event until after processing a DoubleClick event.

I need to use MouseDown, but I also have to check for a double-click.  The double-click needs to take precedence over an ordinary mouse down event.

Can the MouseDown event be delayed?
0
Comment
Question by:jdthedj
9 Comments
 
LVL 20

Expert Comment

by:Madshi
Comment Utility
"dcu2du".
That's what I've written on top of my tools unit. It's the order of the mouse messages. "d=down; c=click; u=up; 2=double click".
So you see, the second mouse down comes AFTER the double click event. So all you have to do is set a variable in the double click event that the next down event must not be handled.
Or do you want to delay the FIRST mouse down event? That will not be possible, because at that time noone knows (perhaps even the user not) whether it will be a single or a double click.

Regards, Madshi.
0
 
LVL 3

Author Comment

by:jdthedj
Comment Utility
Hi Madshi - Thanks for replying

Thanks for the order of processing - it helps a bit - I think, but my application works in a similar way to a lot of regular windows programs - the user may either double-click an item, or single click and then click OK.  

I have to use MouseDown to retrieve the X and Y coordinates of the hotspot area so that I know that the user has clicked in the right place.

Any ideas??
0
 

Expert Comment

by:makli
Comment Utility
hy,

It's simple. in the mousedown procedure, just call the doubleClick event with the correct parameters in the first statement. So in this way, a doubleclick event is called before the mousedown event.

but beware: this is very tricky.
greetings,

makli
0
 
LVL 2

Expert Comment

by:Thaddy
Comment Utility
What you want is very easy to achieve using the OnMousemove event.
This event (from Tcontrol, but not always published) fires when the mouse is over the control. And that seems to be the only thing you want?
example:

procedure TForm1.Button1MouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
begin
 Caption:='Yes, i"m here';
end;

0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
LVL 20

Expert Comment

by:Madshi
Comment Utility
You mean, you need the position of the mouse at the time the double click has happened?
You could write an own message handler for the WM_LBUTTONDBLCLK message. Windows tells you the position with this message. Delphi hides the position, don't know why.

Add this to your main form:
  private
    procedure LButtonDblClick(var Message: TMessage); message WM_LBUTTONDBLCLK;

Regards, Madshi.
0
 
LVL 3

Author Comment

by:jdthedj
Comment Utility
Thanks for the replies.  I think I still need to clarify a bit.

If a person double-clicks I need to IGNORE an OnClick event or a MouseDown event, but the problem is that a single click or a mouse down event fires before the double click event.  

Any thoughts?  
0
 
LVL 20

Expert Comment

by:Madshi
Comment Utility
Ok, how about that:
you could do nothing but set a timer in the MouseDown or MouseClick event that is fired before the double click event.
Then, if the double click event is fired before the timer has expired, you could stop the timer and do the double click action. Otherwise, when the timer has expired and there were no double click event in the meanwhile you could do the mouse down/mouse click action.
Have I understood this time, what you need?
If I have, this is the only way I can image to solve your problem...

Regards, Madshi.
0
 
LVL 3

Author Comment

by:jdthedj
Comment Utility
Hi Madshi - Thanks for your patience.

You have shown me what to do, so if you would like to turn your latest reply into an answer I will give you the points.  Thanks again.

Sorry Makli, but your answer was not quite what I was looking for.
0
 
LVL 20

Accepted Solution

by:
Madshi earned 100 total points
Comment Utility
Thanx, jdthedj...    :-)
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now