• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
NSTextField not getting mouseDown
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSTextField not getting mouseDown


  • Subject: NSTextField not getting mouseDown
  • From: Sander Stoks <email@hidden>
  • Date: Thu, 22 Oct 2009 16:08:54 +0200

Hello all,

Executive summary: I have an NSTextField in an NSPanel which, under certain circumstances, doesn't receive mouseDowns anymore. Specifically, this happens after I end editing with Enter (instead of Tab)

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:

- (BOOL)canBecomeKeyWindow {
	return m_focusRequested;
}

- (void)requestFocus {
	m_focusRequested = YES;
}

- (void)resignFocus {
	m_focusRequested = NO;
}

In the textfield, when it gets a textDidEndEditing message, I send "resignFocus" to the panel. This works.

But: if I cause editing to end by pressing the Enter key (instead of Tab), and then give another window the focus, clicking on the textfield doesn't cause a mouseDown to be receive anymore. The contents of the textfield stay selected (the focus ring is, of course, gone). Therefore, my panel keeps returning NO from canBecomeKeyWindow because it never got a focusRequested message.

Apologies for the long post, but I wanted to make sure I'm approaching this the right way.

I also overrode acceptsFirstMouse in my textfield, returning YES, but that doesn't make a difference.

Thanks for any insights,
regards,
Sander

_______________________________________________

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


  • Follow-Ups:
    • Re: NSTextField not getting mouseDown
      • From: Jens Alfke <email@hidden>
    • Re: NSTextField not getting mouseDown
      • From: Graham Cox <email@hidden>
  • Prev by Date: Re: Opening a NSSavePanel as a Sheet, and blocking like in [panel runModal]
  • Next by Date: NSScroller graphical lag/glitches
  • Previous by thread: Re: to implement a 1 sec repeating timer in a separate thread
  • Next by thread: Re: NSTextField not getting mouseDown
  • Index(es):
    • Date
    • Thread