Leo and OSX and keyboard events and the Meta key

72 views
Skip to first unread message

Karsten Wolf

unread,
Jun 8, 2016, 6:47:11 PM6/8/16
to leo-editor
Hi.


For using Leo on OSX I started redefining lots of shortcuts to the Control key (on OSX == Meta) because keys such as Ctrl-H (== Cmd-H on OSX) for editing the headline is caught by the System and hides the frontmost app. Also the usual editing shortcuts a mac user expects are very different.

To my surprise, my newly added shortcuts did worse than nothing. For example Meta-t (== Ctrl-t == focus outline) inserted a "t" character in the body.

After a digging session in leoPyRef.leo with many g.trace() & g.pdb() I narrowed it down to the functions LeoQtEventFilter.qtMods() and LeoQtEventFilter.toStroke().

As far as I understand it, the Meta key is not recognized by the event machinery. Meta keys can be defined, are listed as defined but are ignored when executed.

Adding

('Meta-', 'Meta+'),

to the table definition in toStroke()

and patching qtMods()

-                (qt.MetaModifier, 'Alt'), # For Microsoft keyboard.
+                (qt.MetaModifier, 'Meta'), # For Microsoft keyboard.

made the Control key available as Meta.

This all is on OSX 10.6 with Anaconda Python and with this modification and the more mac like shortcuts Leo is very usable. I don't know what these changes will do on other platforms but I'm curious if I've missed something or nobody ever used the Meta key?

-karsten

Edward K. Ream

unread,
Jun 13, 2016, 12:18:19 PM6/13/16
to leo-editor
On Wed, Jun 8, 2016 at 3:22 PM, 'Karsten Wolf' via leo-editor <leo-e...@googlegroups.com> wrote:


Adding

​​
('Meta-', 'Meta+'),

to the table definition in toStroke()

and patching qtMods()

-                (qt.MetaModifier, 'Alt'), # For Microsoft keyboard.
+                (qt.MetaModifier, 'Meta'), # For Microsoft keyboard.

made the Control key available as Meta.

Many thanks for this good work. Rev d03bea4 makes the changes you suggest.  All is well on Windows, but not tested yet on MacOS.

The change you suggest in qtMods actually the two tables identical, so rather than changing the one line as you suggest I simply eliminated the darwin-only version of the table.
This all is on OSX 10.6 with Anaconda Python and with this modification and the more mac like shortcuts Leo is very usable. I don't know what these changes will do on other platforms but I'm curious if I've missed something or nobody ever used the Meta key?

​I don't recall the history of this code, except that there has been some history ;-)  The changes you suggest seems natural, and we'll have plenty of time to test them.

EKR

Karsten Wolf

unread,
Jun 13, 2016, 12:54:51 PM6/13/16
to leo-e...@googlegroups.com
...
> Many thanks for this good work. Rev d03bea4 makes the changes you suggest.
> All is well on Windows, but not tested yet on MacOS.

I'm running it daily for a week or so on 10.6 and 10.10 from the same source and the errors I encounter are mine, then some lack of understanding what's happening and then some lack of documentation.

Suggestions for docs will follow... or have I overseen the tutorial to convert a Python project to Leo? Converting @auto nodes (for the import) to @clean nodes to make them structurally editable?

-karsten

Karsten Wolf

unread,
Jul 30, 2016, 3:53:08 AM7/30/16
to leo-editor
I published my leo settings file with the mac shortcuts on github


Comments, corrections and enhancements welcome.

-karsten
Reply all
Reply to author
Forward
0 new messages