• 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: Click to edit
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Click to edit


  • Subject: Re: Click to edit
  • From: Jens Alfke <email@hidden>
  • Date: Sat, 12 Jul 2008 21:46:39 -0700


On 12 Jul '08, at 7:50 PM, Stefan Arentz wrote:

I would like to use text labels that turn into editable text fields when you click them. Like Address Book has when you edit an address card. Does anyone know how those work? Is it a matter of flipping the editable property or are those custom controls?

You can implement a text field like that fairly easily; I have one that's a subclass of NSTextField overriding two methods (see below).


What Address Book does is a different matter. The card is, I believe, a single NSTextView with some tricky delegate methods that control what ranges of the text are editable and selectable.

—Jens

- (void) mouseDown: (NSEvent*)event
{
    if( ! [self isEditable] ) {
        [self setBezeled: YES];
        [self setDrawsBackground: YES];
        [self setEditable: YES];
        self.frame = NSInsetRect(self.frame, -2, -3);
        [self.window makeFirstResponder: self];
    }
}

- (BOOL)sendAction:(SEL)theAction to:(id)theTarget
{
    if( [self isEditable] ) {
        [self setEditable: NO];
        [self setDrawsBackground: NO];
        [self setBezeled: NO];
        self.frame = NSInsetRect(self.frame, 2, 3);
    }
    return [super sendAction: theAction to: theTarget];
}

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________

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: Click to edit
      • From: Stefan Arentz <email@hidden>
References: 
 >Click to edit (From: Stefan Arentz <email@hidden>)

  • Prev by Date: Re: Trigonometric Problem, Particularly tan() Function
  • Next by Date: Re: Triangulating webcams
  • Previous by thread: Click to edit
  • Next by thread: Re: Click to edit
  • Index(es):
    • Date
    • Thread