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: Ron Fleckner <email@hidden>
- Date: Wed, 6 Feb 2008 21:33:39 +1100
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
_______________________________________________
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