Re: Problems with tabbing between custom text fields
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.