• 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
Editing a multi-line NSTextField as a single line
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Editing a multi-line NSTextField as a single line


  • Subject: Editing a multi-line NSTextField as a single line
  • From: Eric Gorr <email@hidden>
  • Date: Tue, 24 Feb 2009 10:34:01 -0500

I start an edit session of a NSTextField by doing the following:

[textField selectText:nil];
NSTextView *currentEditor = (NSTextView*)[textField currentEditor];
NSPoint windowLocation = [theEvent locationInWindow];
NSPoint screenLocation = [[self window] convertBaseToScreen:windowLocation];
NSUInteger characterIndex = [currentEditor characterIndexForPoint:screenLocation];
[currentEditor setSelectedRange:NSMakeRange( characterIndex + 1, 0 )];


However, this text field has a line break mode of NSLineBreakByWordWrapping and does display two lines of text. When editing, I would like the editor which appears to edit this text on just a single line and not do any wrapping.

I was able to accomplish this by doing:

  [[textField cell] setLineBreakMode:NSLineBreakByClipping];

before I start the edit session.

However, I am curious (because I think it would help me understand how the system works) how I could alter currentEditor to accomplish the same thing.

I tried looking at the various classes involved...NSTextView, NSTextContainer, and NSLayoutManager, but didn't see anything obvious.

_______________________________________________

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: Editing a multi-line NSTextField as a single line
      • From: Martin Wierschin <email@hidden>
  • Prev by Date: Re: Capture highlighted menu name
  • Next by Date: RE: [Q] What causes an NSArrayController to know that an entity was inserted via a different window?
  • Previous by thread: Re: [Q] What causes an NSArrayController to know that an entity was inserted via a different window?
  • Next by thread: Re: Editing a multi-line NSTextField as a single line
  • Index(es):
    • Date
    • Thread