• 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
NSButton title inline editing
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSButton title inline editing


  • Subject: NSButton title inline editing
  • From: Sergey Shapovalov <email@hidden>
  • Date: Tue, 17 Apr 2007 13:11:25 +0400

I have a custom view with an NSButtonCell in it, and I want to support inline editing of its title when the user double clicks the button cell (or chooses "Rename" from context menu). How can I do it?

I've found the following method of NSCell class:
- (void)editWithFrame:(NSRect)aRect inView:(NSView *)controlView editor:(NSText *)textObj delegate:(id)anObject event:(NSEvent *)theEvent


But the documentation says, "If the receiver isn’t a text-type NSCell object, no editing is performed". That's what I see in my case: after I say

NSTextView* editor = [[NSTextView alloc] initWithFrame: frame];
[m_buttonCell editWithFrame: frame inView: view editor: editor delegate: self event: event];


a white edit field covers my button cell, but it is not editable. Even if I type something, nothing changes on the screen, and after I press Enter, in textDidEndEditing method of my delegate class, I receive the original title, not what I typed. textDidBeginEditing and textDidChange methods of my delegate class are never called.

My question is: is there a trick to make button cell's title editable just like it can be done for text cells? If no, is there anything less sophisticated than creating an NSTextField control manually at run-time, positioning it over the button cell, and removing it (from screen and from memory) when user input is done?

Thanks in advance for any hint,
Best regards,
Sergey Shapovalov._______________________________________________

Cocoa-dev mailing list (email@hidden)

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:
    • [SOLVED] Re: NSButton title inline editing
      • From: Sergey Shapovalov <email@hidden>
  • Prev by Date: Re: reasonably easy project ideas?
  • Next by Date: How to position a window under a button of another window?
  • Previous by thread: Re: reasonably easy project ideas?
  • Next by thread: [SOLVED] Re: NSButton title inline editing
  • Index(es):
    • Date
    • Thread