• 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:41:01 +0100

On 21. Mar 2004, at 15:18, Allan Odgaard wrote:

[...] However, I re-read your original letter [...]

And then I recalled that you said it actually did work when using the mouse, which puzzled me, but a bit of experiments turned out that the class below works as you want.

What I wrote in my previous letter is still valid, the code below works because I set the drawsbackground and border properties *before* calling super in becomeFirstResponder. The superclass will then obtain the field editor, which will duplicate the visual settings of the text field, then it will be added to the window, causing the real text field to loose focus and reseting border and drawsbackground properties, but that doesn't matter, because it wasn't visible anyway, since it was covered by the field editor (at least the background).

However, I also tried to place the logic in the window and do as outlined in my previous letter, and there is a visual difference, because with the code below, you do *not* get a border on the text field, however, the presence of the border property makes the field editor create a thick focus ring, which sort of looks like a border (but more blurred than a real text field border).

Here is the code, although I do not think that the documentation provide any guarantee that it should give the expected behavior.

@implementation MyTextField
- (id)initWithCoder:(id)aCoder
{
if(self = [super initWithCoder:aCoder])
{
[self setBordered:NO];
[self setDrawsBackground:NO];
}
return self;
}

- (BOOL)becomeFirstResponder
{
[self setDrawsBackground:YES];
[self setBordered:YES];
return [super becomeFirstResponder];
}

- (BOOL)resignFirstResponder
{
[self setDrawsBackground:NO];
[self setBordered:NO];
return [super resignFirstResponder];
}
@end
_______________________________________________
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.


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>)
 >Re: Problems with tabbing between custom text fields (From: Allan Odgaard <email@hidden>)

  • Prev by Date: Re: NSMutableArray problems
  • Next by Date: Re: cocoa blogs?
  • 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