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: Lieven Dekeyser <email@hidden>
- Date: Fri, 15 Feb 2008 16:00:43 +0100
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?
--Lieven
_______________________________________________
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