Skip navigation.
 
mlRe: Set focus on NSView in an NSMenuItem
FROM : Peter Ammon
DATE : Mon Feb 18 20:35:54 2008

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

Related mailsAuthorDate
mlRe: Set focus on NSView in an NSMenuItem Lieven Dekeyser Feb 15, 16:00
mlRe: Set focus on NSView in an NSMenuItem Peter Ammon Feb 18, 20:35