Skip navigation.
 
mlRe: Set focus on NSView in an NSMenuItem
FROM : Pierre Bernard
DATE : Wed Feb 06 11:38:21 2008

Hi Ron!

It appears that both work. I guess it depends on whether you add the 
semi-colon to the selector or not.

The timer was only a wild idea on how to work around the original 
problem with the window's field editor. I got the timer to work, but 
it does not solve the original problem.

Best,
Pierre

On 6 Feb 2008, at 11:33, Ron Fleckner wrote:

>
> On 06/02/2008, at 7:37 PM, Pierre Bernard wrote:
>

>> OK, I figured out how to add a timer. Unfortunately, that does not 
>> help with my problem of the misbehaving field editor.
>>
>> - (void)viewDidMoveToWindow
>> {
>>     [super viewDidMoveToWindow];
>>     
>>     self.focusTimer = [NSTimer timerWithTimeInterval:1.0
>>                                               target:self
>>                                             selector:@selector(focusOnSearchField)
>>                                             userInfo:nil
>>                                              repeats:NO];
>>
>>     [[NSRunLoop currentRunLoop] addTimer:self.focusTimer 
>> forMode:NSEventTrackingRunLoopMode];
>> }
>>
>> - (void)focusOnSearchField
>> {
>>     [[self window] makeFirstResponder:searchField];
>>     
>>     [self.focusTimer invalidate];
>>     self.focusTimer = nil;
>> }
>>
>> Pierre

>
>
> Hi,
>
> not having Leopard I could be just adding noise, but...
>
> Shouldn't your timer's selector method's signature be - 
> (void)focusOnSearchField:(NSTimer *)aTimer ??  That is, the timer 
> should be the argument to the method.
>
> From the (Tiger) docs:
>
>     Discussion
>
>     After seconds have elapsed, the timer fires, sending the message 
> aSelector to target. The aSelector method has the following syntax:
>
>     - (void)myTimerFireMethod:(NSTimer*)theTimer
>
>     The timer passes itself as the argument to aSelector... [and more 
> deleted]
>
>
>
> HTH,
>
> Ron


---
Pierre Bernard
http://www.bernard-web.com/pierre
http://www.houdah.com

Related mailsAuthorDate
mlSet focus on NSView in an NSMenuItem Hendrik Holtmann Jan 4, 15:20
mlRe: Set focus on NSView in an NSMenuItem Peter Ammon Jan 4, 21:30
mlRe: Set focus on NSView in an NSMenuItem Pierre Bernard Feb 6, 00:43
mlRe: Set focus on NSView in an NSMenuItem Pierre Bernard Feb 6, 09:37
mlRe: Set focus on NSView in an NSMenuItem Ron Fleckner Feb 6, 11:33
mlRe: Set focus on NSView in an NSMenuItem Pierre Bernard Feb 6, 11:38
mlRe: Set focus on NSView in an NSMenuItem Lieven Dekeyser Feb 15, 13:55