Click vs Dbl Click

O

oldblindpew

Access doesn't seem able to distinguish between a click and a double click.
I have a form with a Command Button with an "On Click" event procedure.
There is no "On Dbl Click" event for this button. If I double-click this
button, nothing should happen, but what does happen is the "On Click"
procedure runs, which opens a second form with yet another command button in
the same spot. This second command button gets clicked automatically by
Access, thereby running it's event procedure as well. I would like for the
double-click in this context to either do nothing or do the same thing as a
single click, but all my searching and experimenting have yielded nothing.
And may I say I think it is typical of Microsoft that I am now reduced to
taking my tin cup and white cane out on the street begging some charitable
voluteer to help with something that never should have been a problem to
start with.
 
D

Dirk Goldgar

oldblindpew said:
Access doesn't seem able to distinguish between a click and a double
click.
I have a form with a Command Button with an "On Click" event procedure.
There is no "On Dbl Click" event for this button. If I double-click this
button, nothing should happen, but what does happen is the "On Click"
procedure runs, which opens a second form with yet another command button
in
the same spot. This second command button gets clicked automatically by
Access, thereby running it's event procedure as well. I would like for
the
double-click in this context to either do nothing or do the same thing as
a
single click, but all my searching and experimenting have yielded nothing.
And may I say I think it is typical of Microsoft that I am now reduced to
taking my tin cup and white cane out on the street begging some charitable
voluteer to help with something that never should have been a problem to
start with.


A double-click is just a second click immediately following a first click.
A control's DblClick event will not fire unless its Click event fires first,
because the control has in fact been clicked. I don't know of any plausible
way to distingish between "the click that happens on the way to a
double-click" and the simple "click all by itself".

Why are you double-clicking on a button that has no double-click event
procedure?

If this second form's button is a real problem for you, I expect that you
could set that second form up so that the button is initially disabled, and
is only enabled after some small amount of time goes by. You could use the
form's Timer event to do that, I guess.
 
B

Beetle

If I double-click this button, nothing should happen,

Wrong. If you have a Click event, it is going to fire anytime you click the
button, whether you are double-clicking, triple-clicking, etc. makes no
difference.

So, to answer your question (sort of), yes Access *can* tell the difference
between a Click and a Dbl Click. It is doing exactly what you (or someone)
programmed it to do. If you don't want the Click event to fire, don't click
the button (at all).
 
A

Albert D. Kallal

all my searching and experimenting have yielded nothing.
And may I say I think it is typical of Microsoft that I am now reduced to
taking my tin cup and white cane out on the street begging some charitable
voluteer to help with something that never should have been a problem to
start with.

If you use c++, visual basic, vb.net c#, you will find the SAME
behavior (you can however "test" the state of a control and then determine
that the button has already been clicked on --- this means both event codes
have to go into the click event. You "might" be able to kluge this in
access by using a static var in the click event, but, I would not bet on
this.

So, some platforms do allow you to distinguish between both events, but it
not normally the case for most development platforms.

You can certainly move your code to the double click event, and remove the
code from the click event. However, you can't prevent the on-click code
running when a double click occurs. In fact, the click event DOES occur two
times (it is doing what it is supposed to do by design). So, if you have
code in both events, then the on-click event will run twice, and the double
click code will run once.

If you don't want code to run when the control is clicked on, you HAVE to
use the double-click event. It very much how most software has worked
for the last 20 years since the introduction of a mouse. A common exception
is some data grid controls, and some web page development languages do
separate both events.
 
O

oldblindpew

Thanks for replying. I'm sure you and others are correct in your statements
of how clicking and double-clicking work, but the way they work seems
fundamentally illogical to me. Either the two events are distinct or they
are not. They appear to be distinct because 1) where a double-click is
required, a single-click will not suffice, 2) if a double-click isn't fast
enough it will not be recognized as such, and 3) in Access, OnClick and
OnDblClick are separate events on the properties pane. They are not even
next to each other in the list.

You asked why (the user) double-clicks a control that has no DblClick event.
As a programmer, it ultimately doesn't matter why a user does anything. My
concern is with what will happen when the user does it. Having noted this, I
will just say that in the Microsoft world we open things by double-clicking.
A sort-of reflex action or "mouse palsy" sets in where things get
double-clicked improperly. The best practice would probably be to give no
response to an inappropriate double-click. A close second would be for the
programmer to look at the context and accept a either a single or double
click if the double-click would not otherwise have any meaning.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top