Giter Club home page Giter Club logo

Comments (3)

IvanoBilenchi avatar IvanoBilenchi commented on June 8, 2024

I think it would be better to position it at the end of the found range. That way the user can just hit the 'backspace' key to delete text (that's the most common scenario). Don't you agree?

from ictextview.

 avatar commented on June 8, 2024

yes, it makes sense

from ictextview.

IvanoBilenchi avatar IvanoBilenchi commented on June 8, 2024

I just had a look into this: while it's indeed possible to do this programmatically within ICTextView, it actually doesn't have the expected results. I'll describe a common scenario: when you search for a match, you're likely typing text into a UISearchBar, UITextField or another UITextView, meaning ICTextView is not the first responder (and the cursor is thereby not shown).

When you hit the "search" button, ICTextView scrolls and highlights the relevant results, but whenever the user taps into it (in order to make the cursor appear), the cursor is placed depending on where the tap event occurred, invalidating any previous automatic cursor placement.

This would probably work if ICTextView automatically became first responder whenever a search is performed, but then the user would lose the ability to perform multiple subsequent searches, not to mention that it's generally bad practice for controls to automatically get focus.

Furthermore, setting the cursor position means calling setSelectedTextRange: or setSelectedRange:, which are extremely inefficient under iOS 6.x and older (they tend to block the UI thread when UITextView is handling a lot of text).

You can see this is not a very nice outcome in any case. If you need this, you may have luck by playing around with setSelectedRange: and ICTextView's rangeOfFoundString property, maybe even with the UIScrollViewDelegate methods, though again you'd have to provide your own workaround to user generated touch events.

from ictextview.

Related Issues (10)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.