Comments (8)
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.
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
andctrl+e
work as described in this comment composition window, butcmd+a
selects all text andcmd+e
adds back-ticks around the selected text or the word where the cursor is.ctrl+d
andctrl+h
work as you describe, butcmd+d
is a browser function for adding a bookmark, andcmd+h
is a system default for hiding the application.ctrl+o
doesn't do anything, andcmd+o
opens a new document in the current application.ctrl+t
does nothing, andcmd+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.
@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 onlyCmd
. 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 useCmd
on Macs.
- 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
- Use
Cmd
and notCtrl
for the menu labels, that apparently confounded me
from guiguts-py.
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
- Do not bind
- On Windows / Linux:
- Bind
Ctrl
keys for Guiguts commands
- Bind
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.
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.
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.
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.
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)
- Add Bookmarks
- Replace `undo_block_begin` and `end` in `misc_tools` with the one in `maintext`
- Highlight (single, double) quotes in selection
- Checker dialog entries that begin with a newline display as empty strings HOT 2
- Tcl regex bug
- Normalize decomposed UTF-8 characters
- Unicode character entry tools HOT 1
- Page separator lines should take priority in setting page marker locations
- License evaluation HOT 2
- Put some error checking into Footnote Fixup
- Show "Suspects only" in Footnote Fixup
- Page marker flag bug HOT 1
- Potential error count improvement for checker dialogs HOT 1
- Improve S/R page break positioning algorithm
- Make case change respect page break boundaries
- Astral plane characters not handled well by S/R dialog fields HOT 3
- Simplify use of toggle buttons and PersistentBoolean/Int variables
- Files slow to load
- Word Frequency: Initial Caps & Mixed Case don't find anything if Ignore Case is set HOT 8
- Add way to increase (at least some) font sizes
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from guiguts-py.