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

Detect OS X and use appropriate keyboard shortcuts #25

Closed
airstruck opened this issue Jan 25, 2016 · 6 comments
Closed

Detect OS X and use appropriate keyboard shortcuts #25

airstruck opened this issue Jan 25, 2016 · 6 comments

Comments

@airstruck
Copy link
Owner

In general, shortcuts on OS X should use command key instead of control key.

Use love.system.getOS() == 'OS X' in Love and SDL_GetPlatform() == 'Mac OS X' in SDL to figure out if user is on a Mac.

Add a special function like Backend.isControlPressed that detects command key on Mac and control key everywhere else. Is there a better name for this, some word that refers to either a command or control key?

@airstruck airstruck added this to the 0.1.x milestone Jan 25, 2016
@airstruck
Copy link
Owner Author

@rm-code any thoughts on this?

What about shortcut attribute, if someone creates a widget with a shortcut like 'ctrl-s' should that be command-s on a Mac? Is the control key not something an application usually cares about as a modifier on Mac, like the Windows logo key on Windows (something that belongs more to the window manager than to individual apps)?

@rm-code
Copy link
Contributor

rm-code commented Jan 25, 2016

@airstruck The ctrl key is used on OSX in some cases and shouldn't be replaced by default. How about making the keys interchangeable? They could be loaded like a theme then:

local Keymap = {
    ['OSX'] = { -- Backend returns same identifier regardless of SDL or LÖVE.
        text_moveCaretRight = { 'lgui', 'rgui' },
        -- ... 
    },
    ['Windows'] = {
        text_moveCaretRight = { 'lctrl', 'rctrl' },
        -- ...
    }
}
moveCaretLeft(self, Backend.isKeyDown( Keymap[Backend.getOS()].text_moveCaretLeft ))

Just a quick and dirty idea.

If not then I'd simply suggest adding special cases like I did in #24. Shouldn't be too many anyway.

@airstruck
Copy link
Owner Author

Here's the thing I'm mostly worried about, actually. When a Windows user creates a UI with something like:

{ type = 'button', text = 'Save', shortcut = 'ctrl-s' }

What does this mean on a Mac? Should they press ctrl-s to save, or cmd-s?

Maybe UI author could write something like shortcut = 'c-s' to mean ctrl-s on Win and cmd-s on Mac?

@rm-code
Copy link
Contributor

rm-code commented Jan 25, 2016

Well ctrl-s would simply be ctrl-s on a mac. How about simply allowing multiple keys for the shortcut?

{ type = 'button', text = 'Save', shortcut = { 'ctrl-s', 'lgui-s' }

The problem with forcing ctrl to be cmd on OSX automatically is that you'd essentially take away one key from Mac users 😁

@airstruck
Copy link
Owner Author

Doesn't #24 also leave Mac users with one less key? ctrl-a still selects all on Mac, so you can't use it for something else.

I just pushed a commit that has shortcuts treat ctrl and lgui/rgui as both being a ctrl key, so a shortcut = 'ctrl-s' can be activated with either ctrl-s or command-s. It's far from perfect and I'm definitely open to any suggestions for improving it, but I don't think I want users to have to write things like shortcut = { 'ctrl-s', 'command-s' } everywhere.

Multiple shortcuts per widget is a good idea in general though, should probably support that anyway.

@rm-code
Copy link
Contributor

rm-code commented Jan 26, 2016

Doesn't #24 also leave Mac users with one less key? ctrl-a still selects all on Mac, so you can't use it for something else.

That's true if we don't have different key maps for osx and windows. No idea how to implement that nicely though.

I think the current approach is okay for now 👍

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

2 participants