Giter Club home page Giter Club logo

Comments (8)

windymilla avatar windymilla commented on June 20, 2024 2

For @windymilla & @srjfoo: Potentially useful info when attempting to debug/fix key bindings on Mac: https://wiki.tcl-lang.org/page/Modifier+Keys
It appears things are different between the X11 version of Tk (GG1) and the Aqua version (GG2) which will hopefully explain why things aren't working as expected.

from guiguts-py.

srjfoo avatar srjfoo commented on June 20, 2024

I've worked off and on with @windymilla to get the shortcuts working better for Macs, and I think we've definitely improved things, but there were just some key bindings that we couldn't get working with the cmd key.

I have never learned emacs-style key bindings, so unless they map to Mac system defaults ... which they don't, that's something to learn.

Picking a couple out of your list above

  • ctrl+a and ctrl+e work as described in this comment composition window, but cmd+a selects all text and cmd+e adds back-ticks around the selected text or the word where the cursor is.
  • ctrl+d and ctrl+h work as you describe, but cmd+d is a browser function for adding a bookmark, and cmd+h is a system default for hiding the application.
  • ctrl+o doesn't do anything, and cmd+o opens a new document in the current application.
  • ctrl+t does nothing, and cmd+t opens a new tab in the current window.

So, trying to do a direct mapping of keyboard shortcuts from ctrl to cmd would be disruptive.

I don't pretend to know what the answer is, but I don't think that changing the meaning of cmd+a from "select all text in the file" to "move the cursor to the beginning of the file" is a good idea. I think there will be some lively conversations around key binding, but hopefully it'll be easier to get something working in python than it was in perl.

from guiguts-py.

tangledhelix avatar tangledhelix commented on June 20, 2024

@srjfoo This comment confused me...

there were just some key bindings that we couldn't get working with the cmd key

so I decided to open Guiguts and try some common commands with Cmd instead of Ctrl (Find, Paste, ...) and what do you know, they work! I had no idea... since all of the menus say Ctrl I assumed that the Cmd variants weren't bound. I was pretty sure they weren't... perhaps they weren't when I started using Guiguts, and they were added later and I missed the change...

With this new insight in hand, I'll adjust my proposal to this smaller one:

  • Don't bind the Ctrl keys in this new version; bind only Cmd. It's the "right way" on Mac, the platform-native way.
    • That would happen to let Emacs bindings work as a side effect, but even without that benefit, I still think it's the right move - having Ctrl bindings is very strange on Mac apps, I can't think of any others that use them instead of Cmd. Even Microsoft Office apps use Cmd on Macs.
  • Use Cmd and not Ctrl for the menu labels, that apparently confounded me

from guiguts-py.

tangledhelix avatar tangledhelix commented on June 20, 2024

Responding to this:

I don't pretend to know what the answer is, but I don't think that changing the meaning of cmd+a from "select all text in the file" to "move the cursor to the beginning of the file" is a good idea.

To be more clear, I wasn't proposing that. I propose that the Guiguts commands are not bound to Ctrl on Mac at all, and bound only to Cmd. As a natural side effect, that means Emacs keys should work, because Guiguts would not be using those bindings for itself. But that's just a nice-to-have. I assert that even without Emacs keys, it's the correct way to build applications on the Mac platform.

Taking a few common commands as examples, you would end up with a map like this. The keys don't conflict (within any one platform).

Command Win / Linux Mac Source of binding
Select All Ctrl-A Cmd-A Guiguts
Move cursor to beginning of line Ctrl-A macOS default
Search and Replace Ctrl-F Cmd-F Guiguts
Move cursor to right Ctrl-F macOS default
Copy Ctrl-C Cmd-C Guiguts
Paste Ctrl-V Cmd-V Guiguts

I hope that's more clear. I propose this:

  • On Mac:
    • Do not bind Ctrl keys
    • Bind only Cmd keys for Guiguts commands
  • On Windows / Linux:
    • Bind Ctrl keys for Guiguts commands

Apple's Human Interface Guidelines (which are taken almost as gospel by Mac & iOS developers), have this to say about keyboard shortcuts. The below is trimmed, both to emphasize my point, and to avoid a giant paste - the full text is available at the link.

Respect standard keyboard shortcuts.
People expect the standard keyboard shortcuts to work, regardless of the app they’re using. You can also help people learn your app quickly by supporting the standard keyboard shortcuts that make sense in your app.

Prefer the Command key as the main modifier key in a custom keyboard shortcut.
Most standard keyboard shortcuts use the Command key, so people are familiar with it.

Prefer the Shift key as a secondary modifier when the shortcut complements another shortcut.

As much as possible, avoid using the Control key as a modifier.
The system uses Control in many systemwide features, like moving focus or capturing screenshots.

from guiguts-py.

windymilla avatar windymilla commented on June 20, 2024

tl;dr - I agree in principle that keyboard shortcuts should match platform-specific defaults where possible. If we have to have a Prefs setting to give users more choice, then so be it, but ideally we shouldn't need to.

Longer version:
Historically, GG1 has/had lots of Ctrl shortcuts, and set these up on all devices, and shows them in the menus. A few (and more recently an increased number) also have Cmd versions of them that work on Macs, but the Ctrl versions are also bound on Macs.

In what I have done so far in GG2, I have avoided that, and instead have included two ways to keep platform defaults. See init_edit_menu for an example:

        menu_edit.add_button("~Undo", "<<Undo>>", "Cmd/Ctrl+Z")
        menu_edit.add_button(
            "~Redo", "<<Redo>>", "Cmd+Shift+Z" if is_mac() else "Ctrl+Y"
        )

Where Undo is set up, the shortcut Cmd/Ctrl+Z is passed in, which the lower routine interprets as Cmd+Z on a Mac, and Ctrl+Z elsewhere.
Where Redo is set up, that wasn't possible, because the keys are actually different, hence the use of "Cmd+Shift+Z" if is_mac() else "Ctrl+Y"
Do you think continued use of the combination of those mechanisms should satisfy your sugggestion?

Note that I haven't seen GG2 running on a Mac, so can't be sure that Cmd+Z works and is shown in the menu, but if it doesn't then that's a bug which should be addressed.

from guiguts-py.

srjfoo avatar srjfoo commented on June 20, 2024

Note that I haven't seen GG2 running on a Mac, so can't be sure that Cmd+Z works and is shown in the menu, but if it doesn't then that's a bug which should be addressed.

Cmd+Z works on my MBP, and shows in the menu (though still greyed out as inactive), but Cmd+Shift+Z for Redo, while it shows, does not work.

from guiguts-py.

srjfoo avatar srjfoo commented on June 20, 2024

I'll be very pleased if that helps. I did notice in reading through the Aqua section that the most recent OS mentioned was 10.8, and macOS is way beyond that now. So, 🀞 !

from guiguts-py.

windymilla avatar windymilla commented on June 20, 2024

Also, here is an old document detailing default key bindings for Text widgets: https://www.tcl.tk/man/tcl8.3/TkCmd/text.html#M141

from guiguts-py.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.