Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How do I differentiate between OnClick and OnDblClick

1,075 views
Skip to first unread message

Jonathon Doran

unread,
Nov 2, 1998, 3:00:00 AM11/2/98
to
I have an application which needs to do one task when the user single clicks
with the mouse, and another task when they doubleclick. In my component, I
have overridden OnClick and OnDblClick, and when I run the app I find that
double-clicking causes both functions to be called.

Is there a way to avoid the OnClick call, when the user is double-clicking?

(The application is a graphical editor, where clicks change the form, and
double-clicks bring up an edit dialog. Changing the data when the user wants
to edit isn't pleasing me at the moment).

Also, undoing the change is an ackward fix which I would also like to avoid.

Jon Doran

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own

Glatzfamly

unread,
Nov 3, 1998, 3:00:00 AM11/3/98
to
Have you considered changing one of the events to fire on a right mouse button
click?

********************************
Michael Glatz
glatz...@aol.com
mgl...@briefcase.com

Alan Gauld

unread,
Nov 3, 1998, 3:00:00 AM11/3/98
to
Jonathon Doran wrote:
> Is there a way to avoid the OnClick call, when the user is double-clicking?

Horrible hack but I used an isDoubleClick flag....

Alan G.

AlanGLLoyd

unread,
Nov 3, 1998, 3:00:00 AM11/3/98
to

In article <71ld8l$r5$1...@nnrp1.dejanews.com>, dor...@colorado.edu (Jonathon
Doran) writes:

>I have an application which needs to do one task when the user single clicks
>with the mouse, and another task when they doubleclick. In my component, I
>have overridden OnClick and OnDblClick, and when I run the app I find that
>double-clicking causes both functions to be called.
>

>Is there a way to avoid the OnClick call, when the user is double-clicking?
>

>(The application is a graphical editor, where clicks change the form, and
> double-clicks bring up an edit dialog. Changing the data when the user
>wants
> to edit isn't pleasing me at the moment).
>
>Also, undoing the change is an ackward fix which I would also like to avoid.
>

Unless you wait after the OnClick for slightly longer than the system
double-click time, and then check that a double-click has not been made, you
cannot differentiate them.

As the wait for the double-click would make your application appear slow at
this point, it would be better to use the right button, or a modifier key (eg
Ctrl-Click).

Alan Lloyd
alang...@aol.com.

ull...@math.okstate.edu

unread,
Nov 3, 1998, 3:00:00 AM11/3/98
to
In article <71ld8l$r5$1...@nnrp1.dejanews.com>,

dor...@colorado.edu (Jonathon Doran) wrote:
> I have an application which needs to do one task when the user single clicks
> with the mouse, and another task when they doubleclick. In my component, I
> have overridden OnClick and OnDblClick, and when I run the app I find that
> double-clicking causes both functions to be called.
>
> Is there a way to avoid the OnClick call, when the user is double-clicking?

No. Think about it. The user clicks the mouse. Now at that moment
how can the system know whether that's a single click or the first half
of a double-click? Delphi would need to look into the future.

> (The application is a graphical editor, where clicks change the form, and
> double-clicks bring up an edit dialog. Changing the data when the user wants
> to edit isn't pleasing me at the moment).
>
> Also, undoing the change is an ackward fix which I would also like to avoid.
>

Finn Tolderlund

unread,
Nov 3, 1998, 3:00:00 AM11/3/98
to
Jonathon Doran <dor...@colorado.edu> skrev i artiklen
<71ld8l$r5$1...@nnrp1.dejanews.com>...

> I have an application which needs to do one task when the user single
clicks
> with the mouse, and another task when they doubleclick. In my component,
I
> have overridden OnClick and OnDblClick, and when I run the app I find
that
> double-clicking causes both functions to be called.

This is the way it works as you have experienced.

> (The application is a graphical editor, where clicks change the form, and
> double-clicks bring up an edit dialog. Changing the data when the user
wants
> to edit isn't pleasing me at the moment).

If you don't want to perform the OnClick if an OnDblClick follows then I
would advice you to consider to redesign your program. That will make life
easier for you and for the user.

Finn Tolderlund


Jonathon Doran

unread,
Nov 3, 1998, 3:00:00 AM11/3/98
to
In article <19981103005439...@ng40.aol.com>,

glatz...@aol.com (Glatzfamly) wrote:
> Have you considered changing one of the events to fire on a right mouse button
> click?
>

Thanks to all who responded. For some reason I thought the system held mouse
click events until after the double-click time had expired. Thereby allowing
apps to distinguish the events. It looks like I was wrong there.

Given this, I'll try using the right mouse button.

0 new messages