Migrated util.m and the new NSTextField functions.

This commit is contained in:
Pietro Gagliardi 2018-05-04 20:26:13 -04:00
parent 1381edfa6e
commit 2f92f644b5
7 changed files with 15 additions and 14 deletions

View File

@ -1,10 +1,3 @@
// util.m
extern void disableAutocorrect(NSTextView *);
// entry.m
extern void finishNewTextField(NSTextField *, BOOL);
extern NSTextField *newEditableTextField(void);
// window.m
@interface libuiNSWindow : NSWindow
- (void)libui_doMove:(NSEvent *)initialEvent;

View File

@ -176,7 +176,7 @@ static void defaultOnChanged(uiEntry *e, void *data)
}
// these are based on interface builder defaults; my comments in the old code weren't very good so I don't really know what talked about what, sorry :/
void finishNewTextField(NSTextField *t, BOOL isEntry)
void uiprivFinishNewTextField(NSTextField *t, BOOL isEntry)
{
uiDarwinSetControlFont(t, NSRegularControlSize);
@ -197,11 +197,11 @@ static NSTextField *realNewEditableTextField(Class class)
tf = [[class alloc] initWithFrame:NSZeroRect];
[tf setSelectable:YES]; // otherwise the setting is masked by the editable default of YES
finishNewTextField(tf, YES);
uiprivFinishNewTextField(tf, YES);
return tf;
}
NSTextField *newEditableTextField(void)
NSTextField *uiprivNewEditableTextField(void)
{
return realNewEditableTextField([libui_intrinsicWidthNSTextField class]);
}

View File

@ -27,7 +27,7 @@ NSTextField *newLabel(NSString *str)
[tf setEditable:NO];
[tf setSelectable:NO];
[tf setDrawsBackground:NO];
finishNewTextField(tf, NO);
uiprivFinishNewTextField(tf, NO);
return tf;
}

View File

@ -182,7 +182,7 @@ static uiMultilineEntry *finishMultilineEntry(BOOL hscroll)
[[e->tv layoutManager] setAllowsNonContiguousLayout:YES];
// now just to be safe; this will do some of the above but whatever
disableAutocorrect(e->tv);
uiprivDisableAutocorrect(e->tv);
// see https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/TextUILayer/Tasks/TextInScrollView.html
// notice we don't use the Auto Layout code; see scrollview.m for more details

View File

@ -46,7 +46,7 @@ static CGFloat stepperYDelta(void)
{
self = [super initWithFrame:r];
if (self) {
self->tf = newEditableTextField();
self->tf = uiprivNewEditableTextField();
[self->tf setTranslatesAutoresizingMaskIntoConstraints:NO];
self->formatter = [NSNumberFormatter new];

View File

@ -68,4 +68,11 @@ struct uiprivNextEventArgs {
};
extern int uiprivMainStep(uiprivNextEventArgs *nea, BOOL (^interceptEvent)(NSEvent *));
// util.m
extern void uiprivDisableAutocorrect(NSTextView *);
// entry.m
extern void uiprivFinishNewTextField(NSTextField *, BOOL);
extern NSTextField *uiprivNewEditableTextField(void);
#import "OLD_uipriv_darwin.h"

View File

@ -2,7 +2,8 @@
#import "uipriv_darwin.h"
// LONGTERM do we really want to do this? make it an option?
void disableAutocorrect(NSTextView *tv)
// TODO figure out why we removed this from window.m
void uiprivDisableAutocorrect(NSTextView *tv)
{
[tv setEnabledTextCheckingTypes:0];
[tv setAutomaticDashSubstitutionEnabled:NO];