• 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: How do I inhibi the I beam cursor in a NSTextView
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How do I inhibi the I beam cursor in a NSTextView


  • Subject: Re: How do I inhibi the I beam cursor in a NSTextView
  • From: Douglas Davidson <email@hidden>
  • Date: Wed, 14 Aug 2002 09:46:55 -0700

On Tuesday, August 13, 2002, at 09:13 PM, Tom Gray wrote:

How do I make a subclass of NSTextView not display the I beam cursor?

I have created a subclass of NSTextView for the display of a VT-100 terminal
emulator. It runs great except that if I "click" in the terminal an I beam
cursor appears where I have clicked. I don't want that. The cursor (a green
rectangle) is controlled by a server somewhere and the user should not be
able to "place an insertion point" in the terminal (though I want him to be
able to select text.)

I have chased around with NSTextViews shouldDrawInsertionPoint and with
drawInsertionPointInRect:color:turnedOn to no avail.

Depending on the behavior you want, you could (a) make the text view not editable or (b) implement the delegate method

- (NSRange)textView:(NSTextView *)textView willChangeSelectionFromCharacterRange:(NSRange)oldSelectedCharRange toCharacterRange:(NSRange)newSelectedCharRange;

to control the selection. The insertion point shows up if the selected range has length 0. You may already be implementing the delegate method

- (BOOL)textView:(NSTextView *)textView shouldChangeTextInRange:(NSRange)affectedCharRange replacementString:(NSString *)replacementString;

to control changes to the text.

I generally discourage overriding of NSTextView's keyDown: method, but a terminal emulator is one place where it might make sense to do so--if your terminal's input characteristics are such that you really want to replace NSTextView's key handling wholesale, and you don't want complex input methods and so forth. It might even be the case that key strokes don't show up immediately in the display, but instead go somewhere else for processing before being echoed back. So you could use a non-editable text view, and handle key downs yourself, according to the principles of your emulation. In that case the user would still be able to select and copy text, but the text view would not display an insertion point.

Douglas Davidson
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >How do I inhibi the I beam cursor in a NSTextView (From: Tom Gray <email@hidden>)

  • Prev by Date: URL string escape codes
  • Next by Date: Re: NSThread with Distributed Objects
  • Previous by thread: How do I inhibi the I beam cursor in a NSTextView
  • Next by thread: Re: How to write an Menu Extra
  • Index(es):
    • Date
    • Thread