Made the width of TextFields more reasonable on Mac OS X.

This commit is contained in:
Pietro Gagliardi 2014-08-25 16:07:35 -04:00
parent f6d7797fd6
commit 910f78c7e5
3 changed files with 6 additions and 3 deletions

View File

@ -225,9 +225,9 @@ void areaTextFieldOpen(id area, id textfield, intptr_t x, intptr_t y)
goAreaView *a = (goAreaView *) area;
NSTextField *tf = toNSTextField(textfield);
// see TextField.preferredSize() in textfield_darwin.go
[tf sizeToFit];
// TODO
[tf setFrameSize:NSMakeSize(150, [tf frame].size.height)];
[tf setFrameSize:NSMakeSize(textfieldWidth, [tf frame].size.height)];
[tf setFrameOrigin:NSMakePoint((CGFloat) x, (CGFloat) y)];
[tf setHidden:NO];
[[tf window] makeFirstResponder:tf];

View File

@ -58,6 +58,7 @@ extern id windowContentView(id);
extern void windowRedraw(id);
/* basicctrls_darwin.m */
#define textfieldWidth (96) /* according to Interface Builder */
extern id newButton(void);
extern void buttonSetDelegate(id, void *);
extern const char *buttonText(id);

View File

@ -81,7 +81,9 @@ func (t *textfield) allocate(x int, y int, width int, height int, d *sizing) []*
}
func (t *textfield) preferredSize(d *sizing) (width, height int) {
return basepreferredSize(t, d)
_, height = basepreferredSize(t, d)
// the returned width is based on the contents; use this instead
return C.textfieldWidth, height
}
func (t *textfield) commitResize(a *allocation, d *sizing) {