From 4bede4aa8d673e04ee1157ddb62721fa4e6813d9 Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Mon, 11 Aug 2014 00:17:21 -0400 Subject: [PATCH] Split the autocorrect disabling stuff on Mac OS X into its own function and marked the TextArea TODO as a future plan. --- redo/common_darwin.m | 16 ++++++++++++++++ redo/future | 2 ++ redo/objc_darwin.h | 3 +++ redo/window_darwin.m | 8 +------- 4 files changed, 22 insertions(+), 7 deletions(-) create mode 100644 redo/common_darwin.m diff --git a/redo/common_darwin.m b/redo/common_darwin.m new file mode 100644 index 0000000..3043f21 --- /dev/null +++ b/redo/common_darwin.m @@ -0,0 +1,16 @@ +// 11 august 2014 + +#include "objc_darwin.h" +#include + +void disableAutocorrect(id onwhat) +{ + NSTextView *tv; + + tv = (NSTextView *) onwhat; + [tv setEnabledTextCheckingTypes:0]; + [tv setAutomaticDashSubstitutionEnabled:NO]; + // don't worry about automatic data detection; it won't change stringValue (thanks pretty_function in irc.freenode.net/#macdev) + [tv setAutomaticSpellingCorrectionEnabled:NO]; + [tv setAutomaticTextReplacementEnabled:NO]; +} diff --git a/redo/future b/redo/future index e73fd2b..01bbc95 100644 --- a/redo/future +++ b/redo/future @@ -21,6 +21,8 @@ Area Repaint(rect image.Rectangle) Tree Mac OS X: make sure newScrollView() has the correct parameters for Table and Tree (and that Area has the appropriate ones from both + its own no border) +TextArea + Mac OS X: be sure to call disableAutocorrect() so I don't forget, some TODOs: windows diff --git a/redo/objc_darwin.h b/redo/objc_darwin.h index 14164f0..b95cc07 100644 --- a/redo/objc_darwin.h +++ b/redo/objc_darwin.h @@ -110,4 +110,7 @@ extern uintptr_t pressedMouseButtons(void); extern uintptr_t keyCode(id); extern void areaRepaintAll(id); +/* common_darwin.m */ +extern void disableAutocorrect(id); + #endif diff --git a/redo/window_darwin.m b/redo/window_darwin.m index 7cb97d6..b58c2b8 100644 --- a/redo/window_darwin.m +++ b/redo/window_darwin.m @@ -47,13 +47,7 @@ id newWindow(intptr_t width, intptr_t height) // so we have to turn them off here // thanks akempgen in irc.freenode.net/#macdev // for some reason, this selector returns NSText but is documented to return NSTextView... - // TODO isolate into its own function when (if?) we add TextArea - tv = (NSTextView *) [w fieldEditor:YES forObject:nil]; - [tv setEnabledTextCheckingTypes:0]; - [tv setAutomaticDashSubstitutionEnabled:NO]; - // don't worry about automatic data detection; it won't change stringValue (thanks pretty_function in irc.freenode.net/#macdev) - [tv setAutomaticSpellingCorrectionEnabled:NO]; - [tv setAutomaticTextReplacementEnabled:NO]; + disableAutocorrect((id) [w fieldEditor:YES forObject:nil]); return w; }