Right click generates 2 mousedown events??

M

Mike

When I right click in a TextBox, it generates two mousedown events. Is this
normal, or do I have a problem? Code below illustrates the "problem".

thanks for any insight!!

Private Sub TextBox1_MouseDown(ByVal Button As Integer, ByVal Shift As
Integer, ByVal X As Single, ByVal Y As Single)
Static i As Integer
i = i + 1
Debug.Print i
End Sub

Immediate Window:
1
2
 
N

NickHK

Mike,
I can confirm that behaviour in XL+Word 2000 and also in XL2002. Can't find
an explanation anywhere at the moment, but may be something to do with the
menu item that can appear to cut/copy etc the text in a TextBox.
e.g. ListBox (not editable) does not show this behaviour, but a comboBox
(editable) does.

You could test for the right button, or more correctly the non-primary
button. Something like this:

Dim ProcessClick As Boolean

Private Sub TextBox1_MouseDown(ByVal Button As Integer, ByVal Shift As
Integer, ByVal X As Single, ByVal Y As Single)
If Button <> xlPrimaryButton Then
ProcessClick = Not ProcessClick

If ProcessClick = False Then
Exit Sub
End If
End If
'Your code
End Sub

NickHK
 
M

Michel Pierron

Hi Mike,
Yes, this problem is known for a long time.

Static Click As Integer
Click = Click + 1
If Not Click Mod 2 = 0 Then Exit Sub
' Your code

MP
 

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