From 205995278650f0941ca271cadcaad3971872f3b3 Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Sun, 22 Jun 2014 16:37:17 -0400 Subject: [PATCH] Made LineEdit horizontally scrolling on Mac OS X. I'm not sure how I missed this before o.o --- sysdata_darwin.m | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/sysdata_darwin.m b/sysdata_darwin.m index bdcf725..1119255 100644 --- a/sysdata_darwin.m +++ b/sysdata_darwin.m @@ -12,6 +12,8 @@ #import #import +// general TODO: go through all control constructors and their equivalent controls in Interface Builder to see if there's any qualities I'm missing + extern NSRect dummyRect; #define to(T, x) ((T *) (x)) @@ -123,11 +125,20 @@ id makeCheckbox(void) id makeLineEdit(BOOL password) { + id c; + if (password) - return [[NSSecureTextField alloc] + c = [[NSSecureTextField alloc] initWithFrame:dummyRect]; - return [[NSTextField alloc] - initWithFrame:dummyRect]; + else + c = [[NSTextField alloc] + initWithFrame:dummyRect]; + // Interface Builder does this to make the text box behave properly + // see makeLabel() for other side effects + [[toNSTextField(c) cell] setLineBreakMode:NSLineBreakByClipping]; + // Interface Builder also sets this to allow horizontal scrolling + [[toNSTextField(c) cell] setScrollable:YES]; + return c; } void lineeditSetText(id lineedit, id text) @@ -151,6 +162,7 @@ id makeLabel(void) [label setDrawsBackground:NO]; // this disables both word wrap AND ellipsizing in one fell swoop // we have to send to the control's cell for this + // Interface Builder also sets this for its labels, so... [[label cell] setLineBreakMode:NSLineBreakByClipping]; // for a multiline label, we either use WordWrapping and send setTruncatesLastVisibleLine: to disable ellipsizing OR use one of those ellipsizing styles return label;