Board index » delphi » Double Click Double Trouble

Double Click Double Trouble

In order to handle both single click (to drag or stretch) and double
click (bring up properties dialog) messages I have a function that I
place in the MouseDown code for a descendent of a TPaintbox.

function DoubleClick : boolean ;
begin
  result := ( GetTickCount <= ( gLastClickTime + GetDoubleClickTime ) )
;
  gLastClickTime := GetTickCount ;
end ;

The problem is that the second mouse down message is also passed to the
properties dialog that is going to be opened. If the cursor happens to
be over a future button that button gets the message. The properties
dialog is dynamically created by the way, which means that the message
predates the instance of the item responding. Strange....

Any ideas on how to kill the extra mousedown message? I tried adding
code so that it can only do the processing if the button is visible but
the message isn't being processed until its visible.

I'm already using the right click for a popup menu and would like to
keep the doubleclick as a shortcut to the properties dialog.

Thanks,
Mitch Wolberg,
RockWare, Inc.

 

Re:Double Click Double Trouble


Figured out the solution when I began wondering why I hadn't seen this
happen in similar work. I was using the MouseUp to trigger the buttons
action in the properties dialog. When I switched that to use the OnClick
event all was fine.

Mitch Wolberg,
RockWare, Inc.

Re:Double Click Double Trouble


Mitch,

You might want to try implementing some other solution, rather than trying
to respond to both a click and a double-click event. I've read that it's not
really advisable to use both (sorry, can't remember if that came from
Microsoft or some Delphi publication I was reading...) But if you really
need to use both, you might try looking at the Dragging property of TControl
or the GetCapture API call, which could tell you if you were currently
resizing or dragging a control, and could thus disregard the second
MouseDown...

Randy Wilson
Benchmark Consulting

Quote
Mitch Wolberg <rk...@dnvr.uswest.net> wrote in message

news:3804F482.1CDFF4AA@dnvr.uswest.net...
Quote
> In order to handle both single click (to drag or stretch) and double
> click (bring up properties dialog) messages I have a function that I
> place in the MouseDown code for a descendent of a TPaintbox.

> function DoubleClick : boolean ;
> begin
>   result := ( GetTickCount <= ( gLastClickTime + GetDoubleClickTime ) )
> ;
>   gLastClickTime := GetTickCount ;
> end ;

> The problem is that the second mouse down message is also passed to the
> properties dialog that is going to be opened. If the cursor happens to
> be over a future button that button gets the message. The properties
> dialog is dynamically created by the way, which means that the message
> predates the instance of the item responding. Strange....

> Any ideas on how to kill the extra mousedown message? I tried adding
> code so that it can only do the processing if the button is visible but
> the message isn't being processed until its visible.

> I'm already using the right click for a popup menu and would like to
> keep the doubleclick as a shortcut to the properties dialog.

> Thanks,
> Mitch Wolberg,
> RockWare, Inc.

Re:Double Click Double Trouble


Quote
> You might want to try implementing some other solution, rather than trying
> to respond to both a click and a double-click event. I've read that it's not
> really advisable to use both (sorry, can't remember if that came from
> Microsoft or some Delphi publication I was reading...)

It's ok as long as the double-click action is an extension of the single-click
action. Anything else tends to confuse the user.

Peter Below (TeamB)  100113.1...@compuserve.com)
No e-mail responses, please, unless explicitly requested!

Re:Double Click Double Trouble


Just to clarify, I think this is a fairly standard use of the mouse in
graphical programs.

MouseDown/MouseUp to select, resize and drag an element
DoubleClick to select and open an edit dialog
RightClick to display a popup menu with other options (send to back,
edit, delete, copy, etc.)

My coding might not be standard for this but it does work. There are few
examples of how to do this sort of programming and there were even less
when it was first written in Delphi 1. I only created this problem by
getting a bit fancy and using the Mouse down and up events for some
additional animation in the called form.

Thanks for the suggestions,
Mitch Wolberg,
RockWare, Inc.

Quote
"Peter Below (TeamB)" wrote:

> > You might want to try implementing some other solution, rather than trying
> > to respond to both a click and a double-click event. I've read that it's not
> > really advisable to use both (sorry, can't remember if that came from
> > Microsoft or some Delphi publication I was reading...)

> It's ok as long as the double-click action is an extension of the single-click
> action. Anything else tends to confuse the user.

> Peter Below (TeamB)  100113.1...@compuserve.com)
> No e-mail responses, please, unless explicitly requested!

Other Threads