Mouse-wheel press event

In my application (a CAD application) I need to use the event of pressing the mouse wheel.
Most of programs do it to PAN (drag the image around the screen).
As Xojo doesn’t provide any event for mouse-wheel pressing I’ve used declares to recreate such behaviour.
But I am a Windows user and I know how to do it in Windows, but I have no idea how to do it in OS X.

Can some on help me in this question?

[quote=154196:@Ramon SASTRE]As Xojo doesn’t provide any event for mouse-wheel pressing I’ve used declares to recreate such behaviour.
But I am a Windows user and I know how to do it in Windows, but I have no idea how to do it in OS X.[/quote]

I looked at the NSEvent page https://developer.apple.com/library/mac/documentation/Cocoa/Reference/ApplicationKit/Classes/NSEvent_Class/index.html#//apple_ref/occ/instm/NSEvent/phase for handling mouse events. There are quantities of things, but none about pressing the wheel.

Unless I am mistaken, there seems to be no way to get that event. The most common mouse today, the Magic Mouse, simply does not have a wheel but uses swipe gestures instead. Pressing the mouse casing simply clicks. And the corded mouse does have a very small trackball that acts pretty much like a wheel, but the press down is used by the mouse hardware to simulate holding the left button down (I use it on a PC).

In older PC mice, the third button was obtained by holding both left and right button down. Maybe you could do that ? At the page I linked to, pressedMouseButtons can detect that event.

Xojo cannot detect both buttons pressed, as isContextualClick is true when the right button is the only one down.

Yes Michel. You are right in all you say.
But CAD sector (I’m an architect) works with mice with a “pressable” wheel. I like to observe which laptops students use and still this type of mouse is the most popular.
Of course I can simulate pressing mouse wheel with other (presently I combine Shift and left button), and I don’t try to ask Xojo to do something special for me. I just wanted to know if OS X had this possibility, because I’m totally ignorant about it, but according to your comments it seems I’d better forget about it.
Thanks,

[quote=154365:@Ramon SASTRE]Yes Michel. You are right in all you say.
But CAD sector (I’m an architect) works with mice with a “pressable” wheel. I like to observe which laptops students use and still this type of mouse is the most popular.
Of course I can simulate pressing mouse wheel with other (presently I combine Shift and left button), and I don’t try to ask Xojo to do something special for me. I just wanted to know if OS X had this possibility, because I’m totally ignorant about it, but according to your comments it seems I’d better forget about it.[/quote]

You know, pressing down in the center of the magic mouse which would be the closest equivalent of wheel press is just left and right buttons pressed together.

Since a PC mouse with a wheel can be attached to a Mac, even without an event in Cocoa, it should be possible to tap into the low level USB management to catch the specific signal the mouse generates when mouse press occur. But we are venturing much far away from a simple declare.

You may want to ask people who do CAD on the Mac how they manage PAN. If they use wheel press, then it is possible and just necessary to find out how. If they use another command such as a key+mouse click, then all you have to do is use the same.

As a Mac user since pretty much day one I’d suggest that mouse-wheel click (or middleclick) isn’t a user interface element a Mac user would expect to even exist. The standard method I’d expect to find for panning in a window would be scroll wheel for up and down, and SHIFT+ scroll wheel for left to right. Hope that’s some help.

Ramon, I think you may find this thread interesting :
https://discussions.apple.com/thread/4197904?start=0&tstart=0

Plus a video about how to pan with a Mac Book Pro
http://www.youtube.com/watch?v=DAEfyT85yDE

Hi Michel.
First of all thank you for your help.
Yes, I know I can PAN with the TrackPad, but this is not very convenient when precision is required.
I’ve opted for pressing a key + left mouse button. It’s easier. Unfortunately there is not a real standard for this.
For example Rhino ( a very popular CAD program) uses SHIFT + right mouse button to PAN. It is really a good alternative but no so intuitive for most of CAD users, Once you have learned it , any combination is OK.

By the way, I’ve noticed something weird and I don’t know if it is the expected behaviour.

If I use

If Keyboard.ControlKey Or Keyboard.ShiftKey Or Keyboard.OSKey Then

I’ve noticed that Shift and Cmd keys can be pressed before the mouse button to work together with it (as I suppose it must be), while Ctrl key must be pressed after the mouse button.
Is it normal?

I see a chance that the othermousedown value (= 25) could be the event to search for. Sadly, the referenced Handling Mouse Events page in Cocoa Event Handling Guide does not really explain that value … You find it in the NSEvent reference.

In the thread I posted, they talk about Autocad using space-click. Is not Autocad a kind of standard ?

Since MagicPref uses middle click which is both buttons pressed on the Magic Mouse, once can summize it is the closest equivalent possible to wheel press. I believe that can be achieved in Xojo without the need for a third party tool.

For the trackpad pan, space-click seems the most precise solution available.

I did notice othermousedown but as you say it is less than clear. In the past, othermousedown referred to right click.

You can try this with https://dl.dropboxusercontent.com/u/21200221/Xojo/MacOSEvents.xojo_xml_project.zip.

The name promises much more than it holds – it’s just a very basic local NSEvent monitor printing out the event types in Xojo’s debugger (Messages) area. But you should be able to see if it returns a 25 for a middle mouse click. If yes, NSEVent could be a way to go. At least I can say 25 is not a right click – that’s values 3 (down) and 4 (up).

NSEvent pressedMouseButtons returns 1 for left button, 2 for right, then 4, 8, 16, 32 etc for “other buttons” I just dont have a means to tell you what they might be

[quote=154726:@Ulrich Bogun]You can try this with https://dl.dropboxusercontent.com/u/21200221/Xojo/MacOSEvents.xojo_xml_project.zip.

The name promises much more than it holds – it’s just a very basic local NSEvent monitor printing out the event types in Xojo’s debugger (Messages) area. But you should be able to see if it returns a 25 for a middle mouse click. If yes, NSEVent could be a way to go. At least I can say 25 is not a right click – that’s values 3 (down) and 4 (up).[/quote]

This is a precious program to explore events. Thank you for sharing it, Ulrich.

Apparently, the Magic Mouse cannot be used with both sides pushed. The events returned are either 1 for left click or 3 for right click, but no way to do both.

But just for curiosity, I plugged in a PC mouse, and the wheel pressed reports 14 ! Left and right buttons are the same, and no way either to have both at the same time.

So I guess you have provided the solution for Ramon.

If the user wants wheel pressed, he can have it through a PC mouse.

I believe space-click is rather convenient for the Magic Mouse.

That’s great!
I could have survived without this event, but now I can learn to do what I wanted to do.
Again this forum has demonstrated that there a lot of people wishing to help the others.
Thanks, to all of you!

Great to read that, Ramon!
And what better words could there be regarding the coming days?
So good holidays to all of you, have a good time with your friends & families. Let the computer rest too, if you can :wink:

(And if you can’t resist: I updated & subclassed the project so you can receive a NSEvent as a complete class. Some mouse properties have been added – should be easy to extend.)

See you again in a few days!

Ah, those holidays when you are too stuffed to move, don’t dare to work and therefore code a bit for relaxation …

It occured to me I would very much like to be able to query my Apple Magic Trackpad too, so I extended the project a bit more. This is not fully complete but very advanced now, with handlers for every NSEvent (some don’t seem to fire but you need to address their contents once the basic Event occurs – I have done so in many of the example’s event handlers) and even a method to track the system’s elastic scrolling to implement it in your own scroll routines.

A few things are missing, especially a documentation, the ability to add a global event monitor too and a few convenience methods. And I couldn’t test anything. I included a counter to count up to triple mouseclicks, but you can extend this to any number (although I believe many more won’t make much sense). Once I’m done with everything I’ll add this to a separate thread for easier reference.

Healthy digestation days to all of you.

https://dl.dropboxusercontent.com/u/21200221/Xojo/MacOSEvents.xojo_xml_project.zip

[quote=155156:@Ulrich Bogun]Ah, those holidays when you are too stuffed to move, don’t dare to work and therefore code a bit for relaxation …

It occured to me I would very much like to be able to query my Apple Magic Trackpad too, so I extended the project a bit more. This is not fully complete but very advanced now, with handlers for every NSEvent (some don’t seem to fire but you need to address their contents once the basic Event occurs – I have done so in many of the example’s event handlers) and even a method to track the system’s elastic scrolling to implement it in your own scroll routines.

A few things are missing, especially a documentation, the ability to add a global event monitor too and a few convenience methods. And I couldn’t test anything. I included a counter to count up to triple mouseclicks, but you can extend this to any number (although I believe many more won’t make much sense). Once I’m done with everything I’ll add this to a separate thread for easier reference.

Healthy digestation days to all of you.

https://dl.dropboxusercontent.com/u/21200221/Xojo/MacOSEvents.xojo_xml_project.zip[/quote]

I see you relaxed constructively :wink: Thank you for sharing, Ulrich, and congratulations.