diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2020-12-13 13:08:05 +0200 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2020-12-13 13:08:05 +0200 |
commit | 3def602e8b7b6f45003cb95f7a74979118ae0e4a (patch) | |
tree | f7d59c995ba39ee1d57307c4ac74fd02eb046b1c /src/ui/inputwidget.c | |
parent | 730540332cbeaf949263bdf5dae5714688f0d10a (diff) |
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.
Diffstat (limited to 'src/ui/inputwidget.c')
-rw-r--r-- | src/ui/inputwidget.c | 18 |
1 files changed, 18 insertions, 0 deletions
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. */ | |||
30 | #include <SDL_clipboard.h> | 30 | #include <SDL_clipboard.h> |
31 | #include <SDL_timer.h> | 31 | #include <SDL_timer.h> |
32 | 32 | ||
33 | #if defined (iPlatformApple) | ||
34 | # include "macos.h" | ||
35 | #endif | ||
36 | |||
33 | static const int refreshInterval_InputWidget_ = 256; | 37 | static const int refreshInterval_InputWidget_ = 256; |
34 | static const size_t maxUndo_InputWidget_ = 64; | 38 | static const size_t maxUndo_InputWidget_ = 64; |
35 | 39 | ||
40 | static void enableEditorKeysInMenus_(iBool enable) { | ||
41 | #if defined (iPlatformApple) | ||
42 | enableMenuItemsByKey_MacOS(SDLK_LEFT, KMOD_PRIMARY, enable); | ||
43 | enableMenuItemsByKey_MacOS(SDLK_RIGHT, KMOD_PRIMARY, enable); | ||
44 | #else | ||
45 | iUnused(enable); | ||
46 | #endif | ||
47 | } | ||
48 | |||
36 | iDeclareType(InputUndo) | 49 | iDeclareType(InputUndo) |
37 | 50 | ||
38 | struct Impl_InputUndo { | 51 | struct Impl_InputUndo { |
@@ -114,6 +127,9 @@ void init_InputWidget(iInputWidget *d, size_t maxLen) { | |||
114 | } | 127 | } |
115 | 128 | ||
116 | void deinit_InputWidget(iInputWidget *d) { | 129 | void deinit_InputWidget(iInputWidget *d) { |
130 | if (isSelected_Widget(d)) { | ||
131 | enableEditorKeysInMenus_(iTrue); | ||
132 | } | ||
117 | delete_TextBuf(d->buffered); | 133 | delete_TextBuf(d->buffered); |
118 | clearUndo_InputWidget_(d); | 134 | clearUndo_InputWidget_(d); |
119 | deinit_Array(&d->undoStack); | 135 | deinit_Array(&d->undoStack); |
@@ -279,6 +295,7 @@ void begin_InputWidget(iInputWidget *d) { | |||
279 | else { | 295 | else { |
280 | iZap(d->mark); | 296 | iZap(d->mark); |
281 | } | 297 | } |
298 | enableEditorKeysInMenus_(iFalse); | ||
282 | } | 299 | } |
283 | 300 | ||
284 | void end_InputWidget(iInputWidget *d, iBool accept) { | 301 | void end_InputWidget(iInputWidget *d, iBool accept) { |
@@ -287,6 +304,7 @@ void end_InputWidget(iInputWidget *d, iBool accept) { | |||
287 | /* Was not active. */ | 304 | /* Was not active. */ |
288 | return; | 305 | return; |
289 | } | 306 | } |
307 | enableEditorKeysInMenus_(iTrue); | ||
290 | if (!accept) { | 308 | if (!accept) { |
291 | setCopy_Array(&d->text, &d->oldText); | 309 | setCopy_Array(&d->text, &d->oldText); |
292 | } | 310 | } |