• 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
Re: Problems with tabbing between custom text fields
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Problems with tabbing between custom text fields


  • Subject: Re: Problems with tabbing between custom text fields
  • From: Allan Odgaard <email@hidden>
  • Date: Sun, 21 Mar 2004 15:18:22 +0100

On 21. Mar 2004, at 13:58, Alex Penner wrote:

- (BOOL)becomeFirstResponder{
- (BOOL)resignFirstResponder{
Remember to call the super class with these messages.
I'm getting signal 11 (SIGSEGV), after clicking on my custom field?
Are you sure, I have to call super class? As far as I understood from apple docu, I just have to return YES, if text field should become first responder.

Well, if you are writing an NSView subclass you probably can get away with that, because the super class does not have any code in the become/resign first responder methods. But you are subclassing NSTextField, and this class probably will have to do some work when it gets focus.

I tried to create an NSTextField subclass with debug info in the two methods (and had them call super), and it works as expected. However, I re-read your original letter, and what you are attempting to do is not as easy as it might seem.

You see, when you move focus to a text field, it is *not* this text field which handle the actual editing. This is done by a field editor which is obtained by sending fieldEditor:forObject: to the window.

The field editor gets added to the window, and becomes the new first responder (so your original text field loose focus) and it will cover the interior of your original text field (matching the visual settings of that text field), thus hiding the change in 'draws background'.

If you still want to pursue it, then I think the easiest solution is to override fieldEditor:forObject: (in NSWindow), first you call super (to get the field editor) and then, if the object (for which the field editor was requested) is your text field, you send setDrawsBackground:YES to the field editor.

There is still the problem with the border -- since the field editor only covers the interior, then you will need to toggle this for the actual text field -- but you cannot rely on the become/resign first responder methods to reflect what the user perceives. So you will most likely also have to place this logic in the window, although there are also some delegate methods declared in NSControl about when editing starts/stops, but editing is defined as the first key stroke, i.e. not focus.

Hope it helps...
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.


  • Follow-Ups:
    • Re: Problems with tabbing between custom text fields
      • From: Allan Odgaard <email@hidden>
References: 
 >Problems with tabbing between custom text fields (From: Alex Penner <email@hidden>)
 >Re: Problems with tabbing between custom text fields (From: Allan Odgaard <email@hidden>)
 >Re: Problems with tabbing between custom text fields (From: Alex Penner <email@hidden>)

  • Prev by Date: Re: how to get this type of regex matching happening (using AGRegex)?
  • Next by Date: Re: FAQ: minor correction question 3.2.1
  • Previous by thread: Re: Problems with tabbing between custom text fields
  • Next by thread: Re: Problems with tabbing between custom text fields
  • Index(es):
    • Date
    • Thread