2015-04-09 01:35:52 -05:00
|
|
|
// 9 april 2015
|
|
|
|
#import "uipriv_darwin.h"
|
|
|
|
|
|
|
|
@interface uiNSTextField : NSTextField
|
|
|
|
@property uiControl *uiC;
|
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation uiNSTextField
|
|
|
|
|
|
|
|
- (void)viewDidMoveToSuperview
|
|
|
|
{
|
|
|
|
if (uiDarwinControlFreeWhenAppropriate(self.uiC, [self superview])) {
|
|
|
|
[self setTarget:nil];
|
|
|
|
self.uiC = NULL;
|
|
|
|
}
|
|
|
|
[super viewDidMoveToSuperview];
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
// TOOD move elsewhere
|
|
|
|
// 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 :/
|
2015-04-09 10:54:02 -05:00
|
|
|
void finishNewTextField(NSTextField *t, BOOL isEntry)
|
2015-04-09 01:35:52 -05:00
|
|
|
{
|
|
|
|
setStandardControlFont((id) t);
|
|
|
|
|
|
|
|
// THE ORDER OF THESE CALLS IS IMPORTANT; CHANGE IT AND THE BORDERS WILL DISAPPEAR
|
|
|
|
[t setBordered:NO];
|
|
|
|
[t setBezelStyle:NSTextFieldSquareBezel];
|
2015-04-09 10:54:02 -05:00
|
|
|
[t setBezeled:isEntry];
|
2015-04-09 01:35:52 -05:00
|
|
|
|
2015-04-10 16:06:59 -05:00
|
|
|
// we don't need to worry about substitutions/autocorrect here; see window_darwin.m for details
|
2015-04-09 01:35:52 -05:00
|
|
|
|
|
|
|
[[t cell] setLineBreakMode:NSLineBreakByClipping];
|
|
|
|
[[t cell] setScrollable:YES];
|
|
|
|
}
|
|
|
|
|
|
|
|
uiControl *uiNewEntry(void)
|
|
|
|
{
|
|
|
|
uiControl *c;
|
|
|
|
uiNSTextField *t;
|
|
|
|
|
|
|
|
c = uiDarwinNewControl([uiNSTextField class], NO, NO);
|
|
|
|
t = (uiNSTextField *) uiControlHandle(c);
|
|
|
|
t.uiC = c;
|
|
|
|
|
|
|
|
[t setSelectable:YES]; // otherwise the setting is masked by the editable default of YES
|
|
|
|
finishNewTextField((NSTextField *) t, YES);
|
|
|
|
|
|
|
|
return t.uiC;
|
|
|
|
}
|
2015-04-09 10:54:02 -05:00
|
|
|
|
|
|
|
char *uiEntryText(uiControl *c)
|
|
|
|
{
|
|
|
|
uiNSTextField *t;
|
|
|
|
|
|
|
|
t = (uiNSTextField *) uiControlHandle(c);
|
2015-04-10 12:24:34 -05:00
|
|
|
return uiDarwinNSStringToText([t stringValue]);
|
2015-04-09 10:54:02 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void uiEntrySetText(uiControl *c, const char *text)
|
|
|
|
{
|
|
|
|
uiNSTextField *t;
|
|
|
|
|
|
|
|
t = (uiNSTextField *) uiControlHandle(c);
|
|
|
|
[t setStringValue:toNSString(text)];
|
|
|
|
}
|