From 3def602e8b7b6f45003cb95f7a74979118ae0e4a Mon Sep 17 00:00:00 2001 From: Jaakko Keränen Date: Sun, 13 Dec 2020 13:08:05 +0200 Subject: macOS: Disable page navigation while editing text The Cmd+Left/Right keys used both for page navigation (by default) and for moving the cursor inside text editor. The input widget keys should take precedence. --- src/ui/inputwidget.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/ui/inputwidget.c') diff --git a/src/ui/inputwidget.c b/src/ui/inputwidget.c index 59608151..c4c7475e 100644 --- a/src/ui/inputwidget.c +++ b/src/ui/inputwidget.c @@ -30,9 +30,22 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #include +#if defined (iPlatformApple) +# include "macos.h" +#endif + static const int refreshInterval_InputWidget_ = 256; static const size_t maxUndo_InputWidget_ = 64; +static void enableEditorKeysInMenus_(iBool enable) { +#if defined (iPlatformApple) + enableMenuItemsByKey_MacOS(SDLK_LEFT, KMOD_PRIMARY, enable); + enableMenuItemsByKey_MacOS(SDLK_RIGHT, KMOD_PRIMARY, enable); +#else + iUnused(enable); +#endif +} + iDeclareType(InputUndo) struct Impl_InputUndo { @@ -114,6 +127,9 @@ void init_InputWidget(iInputWidget *d, size_t maxLen) { } void deinit_InputWidget(iInputWidget *d) { + if (isSelected_Widget(d)) { + enableEditorKeysInMenus_(iTrue); + } delete_TextBuf(d->buffered); clearUndo_InputWidget_(d); deinit_Array(&d->undoStack); @@ -279,6 +295,7 @@ void begin_InputWidget(iInputWidget *d) { else { iZap(d->mark); } + enableEditorKeysInMenus_(iFalse); } void end_InputWidget(iInputWidget *d, iBool accept) { @@ -287,6 +304,7 @@ void end_InputWidget(iInputWidget *d, iBool accept) { /* Was not active. */ return; } + enableEditorKeysInMenus_(iTrue); if (!accept) { setCopy_Array(&d->text, &d->oldText); } -- cgit v1.2.3