Max Pole
Max Pole

Reputation: 319

Control key usage in Java/Swing on Mac

I got a Swing Application that relies on mouse events combined with two modifier keys (Ctrl & Shift) to control the UI. It works flawlessly on Windows and Linux.

Now, I'd like to make this app running on the Macintosh platform as well. The UI doesn't work out-of-box because the Control key seems to interfere with the right click on my MacBook Pro.

Is there any possibility to get Ctrl-click events working on Mac or should I consider using another key (Alt/Option) instead?

I only care of Mac OS X 10.9 and higher and Java 8.

Thank you in advance!

Upvotes: 2

Views: 1122

Answers (1)

trashgod
trashgod

Reputation: 205865

As shown here, Mac OS X uses control-click to simulate a right-click when using a single-button input device. Using option-click is a common alternative; is an example. For convenience, you may be able to leverage getMenuShortcutKeyMask(), discussed here, which returns Event.CTRL_MASK on Windows/Linux and Event.META_MASK on Mac OS X.

Upvotes: 2

Related Questions