• 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: Typing with multiple selections in NSTextView
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Typing with multiple selections in NSTextView


  • Subject: Re: Typing with multiple selections in NSTextView
  • From: Martin Wierschin <email@hidden>
  • Date: Wed, 19 Sep 2018 09:26:26 -0700

So far as I know this is not possible with a stock NSTextView. The selected
range array is automatically normalized by NSTextView, to sort and coalesce
ranges as needed. If any zero-length ranges are in a given selection array,
only a single zero-length range is allowed and maintained by NSTextView. Any
other zero-length ranges are discarded straight away.

Even if you override selection methods to coerce NSTextView to maintain
multiple zero-length selections, I’d be leery about it doing the right thing
when it comes to text insertion and other behaviors. I doubt it’s written with
multiple zero-length selections in mind. At the very least you’d probably also
need to override text insertion and insertion-point drawing, but who knows what
other things you’d need to shore up.

If I were you and wanted to write this in the safest way possible, to ensure no
unforeseen consequences, I’d probably subclass NSTextView to add a new property
like “multipleInsertionPointIndexes”. Only your own code would need to interact
with this property. Of course you’d still have to add NSTextView overrides to
handle things and keep those indexes in sync, but this would ensure
NSTextView’s code never sees multiple zero-length selections and never
potentially enters unknown states.

Good luck!

~Martin Wierschin


> On Sep 19, 2018, at 12:13 AM, Georg Seifert <email@hidden> wrote:
>
> Hi
>
> Is it possible to make NSTextView to allow typing with multiple insertion
> points? One can set multiple selection and delete all of them at once. But
> typing only replaces the first range and ignores the other ranges.
>
> Thanks
> Georg
> _______________________________________________
>
> 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
>

_______________________________________________

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: Typing with multiple selections in NSTextView
      • From: Georg Seifert <email@hidden>
References: 
 >Typing with multiple selections in NSTextView (From: Georg Seifert <email@hidden>)

  • Prev by Date: Typing with multiple selections in NSTextView
  • Next by Date: Re: Typing with multiple selections in NSTextView
  • Previous by thread: Typing with multiple selections in NSTextView
  • Next by thread: Re: Typing with multiple selections in NSTextView
  • Index(es):
    • Date
    • Thread