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

[SOLVED] Re: NSButton title inline editing


  • Subject: [SOLVED] Re: NSButton title inline editing
  • From: Sergey Shapovalov <email@hidden>
  • Date: Tue, 17 Apr 2007 14:43:35 +0400

My apologies. I solved the problem myself. Inline editing does work after I set editable flag for my button cell:
[m_buttonCell setEditable: YES];


I should have thought about this, so sorry for sending the original message before trying all variants myself. I just assumed that being an NSButtonCell instead of NSTextFieldCell is the reason, while everything appeared to be much more trivial.

Best regards,
Sergey Shapovalov.

On Apr 17, 2007, at 1:11 PM, Sergey Shapovalov wrote:

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


References: 
 >NSButton title inline editing (From: Sergey Shapovalov <email@hidden>)

  • Prev by Date: How to position a window under a button of another window?
  • Next by Date: Re: How to position a window under a button of another window?
  • Previous by thread: NSButton title inline editing
  • Next by thread: How to position a window under a button of another window?
  • Index(es):
    • Date
    • Thread