Re: Set focus on NSView in an NSMenuItem
Re: Set focus on NSView in an NSMenuItem
- Subject: Re: Set focus on NSView in an NSMenuItem
- From: Peter Ammon <email@hidden>
- Date: Mon, 18 Feb 2008 11:35:54 -0800
On Feb 15, 2008, at 7:00 AM, Lieven Dekeyser wrote:
On 15 Feb 2008, at 15:45, Pierre Bernard wrote:
BTW, I also need to add a delegate to the search field for the
action to be sent:
- (void)controlTextDidChange: (NSNotification*)notification
{
NSSearchField* notif_obj = [notification object];
NSString* newStr = [notif_obj stringValue];
if (([newStr characterAtIndex:[newStr length]-1] ==
NSCarriageReturnCharacter) ||
([newStr characterAtIndex:[newStr length]-1] == NSEnterCharacter) )
{
[self myAction:notif_obj];
}
}
Be careful.. If you still need this fix for carriage return and
enter, you'll also want to check other control characters like
backspace, delete, and even the arrow keys. Their unicode character
values are probably just appended to the string value, which is not
what you'd want.
For now, I've just set focus to the view that contains the text
field, and require the user to click in the textfield to get focus
there. The mouse click seems to fix the control characters problem,
so I think it does something more than just makeFirstResponder..
Apple?
Sorry, I don't have a workaround for this issue yet.
-Peter
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden