Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modifier keys in menu items mistaken (Meta, Control) #117

Open
Sciss opened this issue May 4, 2014 · 13 comments
Open

Modifier keys in menu items mistaken (Meta, Control) #117

Sciss opened this issue May 4, 2014 · 13 comments

Comments

@Sciss
Copy link
Contributor

Sciss commented May 4, 2014

I just noticed that when running an application under OS X, the menu item short cuts show wrong modifiers. For example, if a short cut is Meta + A, this is only shown as A. In turn, if I use Ctrl + A, this is shown as + A (using the command symbol rendering for Meta.)

@mgarin
Copy link
Owner

mgarin commented May 11, 2014

I will be running some massive tests on Mac OS X soon and will try to fix all the issues I will find, including this one and other reported.

@mgarin mgarin added this to the Small issues milestone May 11, 2014
@mgarin mgarin self-assigned this May 11, 2014
@Sciss
Copy link
Contributor Author

Sciss commented Jul 23, 2014

I also notice that the default text actions have the wrong modifier Ctrl instead of Meta. On OS X, you expect Cut = Meta-X, Copy = Meta-C, Paste = Meta-V, Select-All = Meta-A, Undo = Meta-Z, Redo = Meta-Shift-Z, instead of Ctrl (Linux, Windows). I'm not sure this is related. Should I open a separate ticket?

@mgarin
Copy link
Owner

mgarin commented Jul 24, 2014

It is related (partially), so one issue is fine :)

This one is the components hotkeys mapping issue. Happened generally because basic look and feel (which is the base for WebLaF) has windows-like hotkeys and it seems that they do not properly change according to underlying OS.

@mgarin
Copy link
Owner

mgarin commented Jul 24, 2014

Btw, I will include this fix in v1.29 update.

@mgarin mgarin removed this from the Small issues milestone Sep 30, 2014
@Sciss Sciss removed this from the Small issues milestone Sep 30, 2014
@mgarin mgarin added this to the v1.29 milestone Sep 30, 2014
@chaddaniels
Copy link

Is this fix still scheduled for 1.29?

@mgarin
Copy link
Owner

mgarin commented Jun 30, 2015

Yes, it is. All bugs which are set to v1.29 milestone will be fixed with v1.29 release. Most of features and enhancements which are set to v1.29 will also be included, but some of those might be re-scheduled for the next update depending on how this release goes.

@rquast
Copy link

rquast commented Apr 2, 2016

Bump.. a customer informed me about this bug today. Is there a patch that can be released for it?

@rquast
Copy link

rquast commented Apr 4, 2016

http://stackoverflow.com/questions/9780028/mac-keyboard-shortcuts-with-nimbus-laf - that solution worked for me as a workaround for each individual component that didn't work properly.

@mgarin
Copy link
Owner

mgarin commented Apr 4, 2016

I started to investigate this one and got kinda stuck. Unfortunately I'm not using mac a lot, so I'm not really sure how hotkeys should be handled there and which hotkeys for which application areas are better.

I have asked a few colleagues who are using Mac OS X a lot and they said that ctrl key is barely used or not used at all. I wonder whether it's true or depends on use cases.

Right now there is an old workaround in WebLaF code that always handles ctrl in HotkeyData class as a menu shortcut key. That way it gets converted into on Mac OS X and acts as ctrl on Windows and Linux. But that obviously disables usage of actual ctrl mask on Mac OS X at all.

So I'd really like to hear your comments about how different hotkeys should be acting on Mac OS X in different application areas. That would help me to correctly adjust the hotkeys handling within the library and avoid similar mistakes in future.

@Sciss
Copy link
Contributor Author

Sciss commented Apr 4, 2016

The two issues:

  • Binding of default action such as Cut/Copy/Paste should use platform specific conventions, so Meta-C/V/X on Mac, Ctrl-C/V/X on Linux and Windows (?)
  • Rendering: You should always render Ctrl modifier as Ctrl character (^) and Meta modifier on OS X as ⌘. If I use Ctrl on Mac, it should still be drawn as Ctrl character. On the Mac you can use both Ctrl and Meta as modifiers, although primary menu actions (e.g. Meta-N/O/S for New/Open/Save) use meta.

I think Nimbus works correctly so could serve as a template.

@mgarin
Copy link
Owner

mgarin commented Apr 4, 2016

Sounds reasonable, but the problem is - Nimbus uses the same keys basic L&F provides.
WebLaF uses those as well except a few components with slightly modified keys.

Here is an example of how L&F keystrokes are defined:

"TabbedPane.ancestorInputMap", new UIDefaults.LazyInputMap(new Object[] {
    "ctrl PAGE_DOWN", "navigatePageDown",
    "ctrl PAGE_UP", "navigatePageUp",
    "ctrl UP", "requestFocus",
    "ctrl KP_UP", "requestFocus",
}),

This specific part is the same for both Nimbus and WebLaF and I couldn't find how exactly hotkeys like ctrl UP are getting used as meta UP in the end. It doesn't seem that any particular code in Nimbus L&F takes care of that.

It seems that MenuShortcut class handles menu hotkeys properly (uses ctrl as meta for menu items), but there is nothing similar for components like JTextField - those seem to use hotkeys directly as they are provided, meaning they will use ctrl as ctrl and not meta if it was provided in key string.

Unfortunately I can't really run any tests on Mac OS X right now - will get my hands on a macbook only tomorrow, so right now I can only ask:
Do textfields with Nimbus L&F installed actually use ⌘+X/C/V instead of ctrl+X/C/V?
By looking at the code it seems that textfields are using ctrl+X/C/V even on Mac OS X.

@Sciss
Copy link
Contributor Author

Sciss commented Apr 4, 2016

I'm also not on Mac now, but from the code you posted that definitely will not use ⌘+X/C/V, so perhaps my memory with Nimbus was wrong. In any case, since Mac has both Ctrl and Cmd, I don't think you need to make adjustments in every possible spot. For example those tabbed pane ones, I'm not even aware they existed. The crucial ones are the commonly used shortcuts that also appear in the edit menu: Meta-X/C/V/A/Z cut/copy/paste/select-all/undo. Redo has this stupid split across platforms - Meta-Shift-Z versus Ctrl-Y. Even on Linux I'm seeing applications randomly using one or the other. I think the nominal standard is Meta-Shift-Z for Mac, Ctrl-Shift-Z for Linux, Ctrl-Y for Windows.

@mgarin
Copy link
Owner

mgarin commented Apr 4, 2016

I'm also not on Mac now, but from the code you posted that definitely will not use ⌘+X/C/V, so perhaps my memory with Nimbus was wrong.

I guess I will check this out tomorrow then, maybe there is something I have missed in the code, some tricky workaround somewhere - Swing is full of those.

In any case, since Mac has both Ctrl and Cmd, I don't think you need to make adjustments in every possible spot. For example those tabbed pane ones, I'm not even aware they existed. The crucial ones are the commonly used shortcuts that also appear in the edit menu: Meta-X/C/V/A/Z cut/copy/paste/select-all/undo.

The main question is whether I will have to do adjustments in L&F defaults or some tricky workarounds for specific components. I will need to test Nimbus first to see how it handles that stuff (if it does at all).

Redo has this stupid split across platforms - Meta-Shift-Z versus Ctrl-Y. Even on Linux I'm seeing applications randomly using one or the other. I think the nominal standard is Meta-Shift-Z for Mac, Ctrl-Shift-Z for Linux, Ctrl-Y for Windows.

To be honest, Ctrl+Y is the worst hotkey ever. Most Windows applications I know are already using Ctrl+Shift+Z and sometimes you can find ones that work with both. Even Notepad is using Ctrl+Shift+Z already and doesn't support Ctrl+Y.

I'd stick with Ctrl(Meta)+Z and Ctrl(Meta)+Shift+Z for all platforms for convenience reasons and just forget Ctrl+Y for good.

@mgarin mgarin modified the milestones: v1.2.9, v1.3.0 Aug 5, 2019
@mgarin mgarin modified the milestones: v1.3.0, v1.2.12 Nov 29, 2019
@mgarin mgarin modified the milestones: v1.2.12, v1.4.0 Jan 10, 2020
@mgarin mgarin removed this from the v1.4.0 milestone Apr 23, 2020
@mgarin mgarin added this to the v1.2.14 milestone Feb 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants