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: Pierre Bernard <email@hidden>
- Date: Wed, 6 Feb 2008 11:38:21 +0100
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
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
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