Edit Links |
Mac /
LyXmodifierKeysCategories: Mac << | Page list | >>Swapping the Command and Control keys for LyX on the MacThe ProblemEarly versions of LyX on Mac used to come with a graphical user interface called xforms, which required an X Window server (X11) to be running and lacked the Aqua-like look-and-feel that is now attainable through the Qt interface. However, the Qt libraries with which current versions of LyX/Mac are built put severe constraints on users' ability to customize the modifier key bindings. Modifier keys are important for users relying heavily on keyboard shortcuts in LyX. The official binaries for LyX/Mac available from the main download page follow Qt's use of "Option" and "Command" (Apple) as modifier keys, leaving the "Control" key non-functional. Two modifier keys (plus the Shift key) are indeed sufficient for LyX, but there are situations when it becomes desirable to break out of this default choice. This is true especially for users who are accustomed to Emacs, a popular all-purpose editor that has a long history on UNIX-like operating systems. Although LyX offers customized bind files which implement many Emacs key bindings, there is one crucial problem: wherever Emacs users expect to press the Control key, LyX requires them to press the Command key instead. This is extremely confusing for people who use both LyX and Emacs side by side. (The "Escape" key in LyX also functions differently from Emacs, because LyX only uses it as a "cancel" key.) SolutionIn LyX 2.0 (starting with alpha 6) or later on Mac OS X, go to Preferences > Editing > Keyboard/Mouse and look for the check box saying "Do not swap Apple and Control Keys." When this box is checked, the Control key acts as Control and the Apple key acts as Meta - i.e., the modifier keys are not swapped. The setting takes effect after relaunching LyX. An exception are the keyboard shortcuts in the Mac-specific LyX nenu: "Preferences", "Hide LyX" and "Quit": they always use the Apple key. History (included only for reference)The rest of this page is now obsolete. You may want to browse this section if you're looking for an older version of LyX (<version 2.0), compiled with a fix for the Control-Apple swap issue. An Initial SolutionOn this page, we collect binaries that fix this problem by re-assigning the role of the modifier keys to make the Control key functional again. For versions up to 1.4.2, this was done by compiling the Qt libraries with a small patch. (Instructions for compiling the patched version can be found on the lyx-users mailing list.) Here are links to binaries for LyX that contain the patch described above:
Most people who use a patched version of LyX also use an operating system-level keyboard mapper like uControl or fkeys to map the Caps Lock key to the Control modifier. The patched versions above do not do this mapping directly. A Better (?) SolutionA major downside of the original solution is that a patched version of LyX needs to be compiled and distributed separately for every release. It would be much better if a single LyX distribution could be configured for either standard and "swapped" behavior. An attempt at this is now available as a new patch for Qt 4 (confirmed to work with versions 4.3.4 through 4.4.3; does not work with 4.5.2), which has been used to create patched versions of the LyX binaries:
You can install the patched version just like the official one. To swap the modifier keys, you will need to add a key called An easy way to do this is to type:
in a Terminal window. Then, using the Property List Editor, select the This new solution has been tested on PPC and Intel Macs running Tiger and Leopard. If you find that it doesn't work as expected, feedback would be greatly appreciated. At this time there does not appear to be enough critical mass among the LyX/Mac user base to warrant compiling the patch in the regular release. (There was some discussion of this issue on the lyx-devel mailing list.) However, the patch source includes a rudimentary shell script (build-universal.sh) that successfully builds the Universal binary on an old PowerPC Mac running OS X 10.4.11. If you're interested in building it yourself (and/or improving the script), this would be a good place to start. Future SolutionsThere is a resolution that doesn't require patching Qt. In looking at the sources of qt-everywhere-opensource-src-4.6.2.tar.gz there is a new ApplicationAttribute constant called Qt::AA_MacDontSwapCtrlAndMeta which can be set by the application. When it is set, the keymapper no longer performs the switch. That means Qt no longer has to be patched, but LyX needs to call setAttribute with this constant when the application loads. On the lyx-devel mailing list, I suggested adding the option to switch Meta and Control directly to the application preferences. I started testing this approach (noeckel, June 5, 2010), and found it has one additional advantage: the menu shortcuts are now displayed correctly in the GUI (i.e., ^S for save if you use emacs bindings). With the older patches, the shortcuts worked fine but they weren't displayed in the pull-down menus. What I did to compile the test version is: In the file /src/frontends/qt4/GuiApplication.cpp add the single line setAttribute(Qt::AA_MacDontSwapCtrlAndMeta); after #ifdef Q_WS_MACX // FIXME: Do we need a lyxrc setting for this on Mac? This behaviour // seems to be the default case for applications like LyX. setQuitOnLastWindowClosed(false); To compile LyX with Qt 4.6.2, you need to set some extra arch flags as described in http://www.mail-archive.com/lyx-devel@lists.lyx.org/msg155084.html. The next step is for the LyX developers to add a Preference entry so that this call can be made depending on the user's settings. For completeness, here are some older discussion items:
Votes for continued support for modifier key swapping
|