ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Right click generates 2 mousedown events?? (https://www.excelbanter.com/excel-programming/377467-right-click-generates-2-mousedown-events.html)

Mike[_110_]

Right click generates 2 mousedown events??
 
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



NickHK

Right click generates 2 mousedown events??
 
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

"Mike" wrote in message
...
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





Michel Pierron

Right click generates 2 mousedown events??
 
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

"Mike" a écrit dans le message de news:
...
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






All times are GMT +1. The time now is 08:03 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com