-stringValue on NSTextfield does not reflect actual contents
-stringValue on NSTextfield does not reflect actual contents
- Subject: -stringValue on NSTextfield does not reflect actual contents
- From: Philip Dow <email@hidden>
- Date: Sat, 22 Jul 2006 22:31:07 +0200
I am building a window in code. It contains a text field and two
buttons, one "OK" the other "Cancel." The window does not use any
bindings and I am running it modally.
The window comes to the fore when the user drags an item onto the
relevant object. The dragged item contains a string which is
initially displayed in the text field. The user can edit that string
value.
If the user presses return when finished editing, calling -
stringValue on the text field returns the correct value. However, if
the user clicks the "OK" button, calling -stringValue returns the
field's initial value rather than the edited version. I'm stumped as
to why it does this.
The code that builds the text field follows:
NSTextField *title = [[NSTextField alloc] initWithFrame:NSMakeRect
(20,60,219,22)];
[title setStringValue:defaultTitle];
[title setSelectable:YES];
[title setEditable:YES];
[title setBezeled:YES];
[title setDrawsBackground:YES];
[title setBezelStyle:NSTextFieldSquareBezel];
[title setAutoresizingMask:NSViewWidthSizable];
[[title cell] setScrollable:YES];
[[title cell] setControlSize:NSRegularControlSize];
[title setFont:[NSFont systemFontOfSize:[NSFont
systemFontSizeForControlSize:NSRegularControlSize]]];
The "OK" button is made to respond to a Return key with [sheetWin
setDefaultButtonCell:[okay cell]];
I grab the text field's string with returnValue = [title stringValue];
Setting an action and target on the text field or setting the
sendsActionOnEndEditing value makes no difference. I'm sure I just
need to add one line of code somewhere, but I don't know what it is.
-Phil
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden