Excel for Mac 2016 right click mousedown mouseup events

Mrock1

Board Regular
Joined
Oct 7, 2014
Messages
78
I have recently migrated an Excel macro driven time recording application from Winodws to Mac. I have overcome most of the differences in the vba macro language and Mac subtleties, but am left with one small frustration. On my main userform I have a listbox. In the Windows version I was able to create a mousedown event routine that displayed details of the selected item in a "hidden" textbox by updating the text property and making the textbox visible when the right mouse (button 2) is pressed. I then have a corresponding mouseup event that makes the textbox invisible again when the right mouse button is released. This worked great for years in Windows. However in moving to Mac (Yosemite and Office 365 2016) I have found that the mouseup event is triggered immediately after the mousedown even though the button has not been reelased. This is not so for the left mouse button as I have change the routine to respond to button 1 instead of 2 and it works as expected. However this is not ideal as the textbox flashes whenever an item is selected or double clicked and I want to run another routine on a selection change anyway which uses the same textbox for a different purpose.

i have also removed all my code from both the mousedown and mouseup routines, even removed the mousedown routine completely but every time I press and hold the right mouse button on any item in the listbox the mouseup routine triggers immediately after the mousedown event has executed although I have not released the button or moved the mouse. As I said before, the left mouse works as I'd expect it should and it's always worked in Windows.

The simplest code I have tried is as follows. The doevents statement is to allow me to create a break point for debug purposes.
Private sub Listbox1_mousedown(byval button as long, byval shift as long, byval X, byval Y as long)
If button = 2 then
DoEvents
End if
End sub

Private sub Listbox1_mouseup(byval button as long, byval shift as long, byval X, byval Y as long)
If button =2 then
DoEvents
End if
End sub

In the above example the mouseup event triggers immediately after the mousedown routine finishes executing when pressing and holding the right mouse button.
if I use button = 1 and the left mouse button then the mouseup routine does not trigger.

Is this some sort of passive protest against multi-button mice on an Apple ;) ?

Any ideas would be greatly appreciated.
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
Having no responses yet, I assume this is a bug or undocumented feature, so I developed a workaround as follows.

In the userform declarations section defined a variable as follows:
Public MouseJustPressed as Boulean

The create your MouseDown and MouseUp events as follows:

Public ListBox1_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
If Button = 2 then
MouseJustPressed
{enter what ever code you need your right-mouse-down to do}
End If
End Sub

Public ListBox1_MouseUp((ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
If Button = 2 then
If MouseJustPressed then
MouseJustPressed = False
Else
{code for mouse release/up}
End If
End If
End Sub

Not ideal, but it works. I hope Microsoft/Apple see the problem and fix it at some stage in the future.
 
Upvote 0

Forum statistics

Threads
1,223,162
Messages
6,170,432
Members
452,326
Latest member
johnshaji

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top