Re: NSTextField not getting mouseDown
Re: NSTextField not getting mouseDown
- Subject: Re: NSTextField not getting mouseDown
- From: Graham Cox <email@hidden>
- Date: Fri, 23 Oct 2009 01:17:04 +1100
On 23/10/2009, at 1:08 AM, Sander Stoks wrote:
Background: I am using NSPanel to make a "tool window" for my app.
This window contains a few buttons, sliders, and an NSTextField. I
wanted this window to avoid becoming key, so that the user can
select a new tool on this window without her main window losing
focus and her having to select it again. I managed to get the right
behavior by overriding canBecomeKeyWindow and returning NO. All
buttons and sliders were fully operable this way.
Until I added an NSTextField, which obviously needs its containing
window to be the key window to work. I couldn't get this
combination of requirements implemented successfully, so I solved it
partially by making my own textfield and panel subclasses; when the
textfield gets a mouseDown, I send a "focusRequested" message to its
panel, which then sets a boolean ivar, like so:
What you want is to remove all this stuff and look at [NSPanel
setBecomesKeyOnlyIfNeeded:] which deals with whatever is necessary for
you. Standard text fields and so on should then work properly.
--Graham
_______________________________________________
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