airstruck / luigi

Lovely User Interfaces for Game Inventors
MIT License
114 stars 23 forks source link

Make shortcut attribute cross-platform friendly? #29

Closed airstruck closed 8 years ago

airstruck commented 8 years ago

Brainstorming ideas for making the shortcut attribute make more sense across platforms.

Consider this example:

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

This is fine on Windows/Linux, but Mac users will want command-s as the shortcut for saving things. Possible solution (this won't actually work yet; shortcuts don't recognize "gui" as a modifier key yet):

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

Now Mac users can press command-s, but they can also press ctrl-s, and Windows/Linux users can press win-s. Only the appropriate shortcut for the user's platform should work.

Another idea:

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

The command- modifier would only be relevant on Mac, and would never be triggered elsewhere. Similarly, option- could be used for the alt key, but only on a Mac. Problem is, ctrl-s still works on Mac, but shouldn't; we'd need something to call the ctrl key that only applies to non-Mac.

And another idea:

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

Here, c-s can mean command on Mac and ctrl elsewhere. This only solves a subset of the problem, but it's probably a large subset and it's a reasonably clean solution.

Current behavior is ctrl- shortcuts really means either ctrl or gui key is pressed, regardless of platform. This should probably change.

Related: #25

airstruck commented 8 years ago

Here's an idea.

Support special mac- and win- modifiers. The mac- modifier is "always on" on Mac, and the (poorly-named) win- modifier is "always on" everywhere else. So you could write:

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

But, also support the special c- modifier mentioned earlier as a shortcut for that, so this would do the same thing:

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

The ctrl- modifier would revert back to meaning just the ctrl keys, not the gui keys.

rm-code commented 8 years ago

Support special mac- and win- modifiers. The mac- modifier is "always on" on Mac, and the (poorly-named) win- modifier is "always on" everywhere else

Sounds like a good solution to me :+1:

airstruck commented 8 years ago

Done, also supports command- as an alias for mac-gui- and option- as an alias for mac-alt-.

Still need to fix up the thing that displays shortcuts in menu items.