• 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
Sub-subclass of NSTextField is defective
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Sub-subclass of NSTextField is defective


  • Subject: Sub-subclass of NSTextField is defective
  • From: John Nairn <email@hidden>
  • Date: Wed, 29 Jun 2005 15:48:34 +0200

I can not get tabbing between NSTextField subclasses to work. This code fragment demonstrates the problem:

1. Tabbing works fine if I create standard NSTextFields with

NSTextField *fld1=[[NSTextField alloc] initWithFrame:NSMakeRect (22,100,150,22.)];
[fld1 setStringValue:@"Custom 1"];
[backgroundView addSubview:[fld1 autorelease]];
NSTextField *fld2=[[NSTextField alloc] initWithFrame:NSMakeRect (22,140,150,22.)];
[fld2 setStringValue:@"Custom 2"];
[backgroundView addSubview:[fld2 autorelease]];


2. But, I need to subclass NSTextField more than once, but even the bare minimum second subclass breaks tabbing between fields. Here is a tested example

    @interface TextCell : NSTextField
    {
    }

    @end

    @interface EditValueCell : TextCell
    {
        BOOL changed;
    }
    @end

    @implementation EditValueCell

    - (id)initWithFrame:(NSRect)cellFrame
    {
        if(self=[super initWithFrame:cellFrame])
        {    changed=NO;
        }
        return self;
    }

    @end

and comparable code that worked for text fields now fails to tab between fields

EditValueCell *fld1=[[EditValueCell alloc] initWithFrame:NSMakeRect(22,100,150,22.)];
[fld1 setStringValue:@"Value 1"];
[backgroundView addSubview:[fld1 autorelease]];
EditValueCell *fld2=[[EditValueCell alloc] initWithFrame:NSMakeRect(22,140,150,22.)];
[fld2 setStringValue:@"Custom 2"];
[backgroundView addSubview:[fld2 autorelease]];


If this code created the first subclass (TextCell instead of EditValueCell) it works, but uses of a second subclass breaks tabbing. I also tried to explicitly connect the key views with the following, but it still breaks tabbing:

    [fld1 setNextKeyView:fld2];
    [fld2 setNextKeyView:fld1];

3. Question: What's going on. All development has stopped until I can support tabbing between fields, but I can not even find anything to try differently to make it work? The above results imply that tabbing in Cocoa only works for NSTextFields or for direct subclasses of NSTextFields, but not for subclasses of subclasses of NSTextField. Is that correct?

---------------
John Nairn (1-801-581-3413, FAX:1-801-581-4816)
Web Page: http://www.mse.utah.edu/~nairn

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Prev by Date: Re: Generating PDFs....
  • Next by Date: Re: How to get information from the download manager?
  • Previous by thread: Re: How to get information from the download manager?
  • Next by thread: sudoish things?
  • Index(es):
    • Date
    • Thread