Skip to content

Improve text selection between TextArea items in ListView#1

Merged
shaan7 merged 1 commit intoshaan7:improvements/v1from
nuttyartist:main
Aug 18, 2023
Merged

Improve text selection between TextArea items in ListView#1
shaan7 merged 1 commit intoshaan7:improvements/v1from
nuttyartist:main

Conversation

@nuttyartist
Copy link
Copy Markdown

@nuttyartist nuttyartist commented Aug 2, 2023

Hello,

Thanks a lot of your code here! It lays the ground for a proof-of-concept for the Block Editor I'm working on for my note-taking app https://github.com/nuttyartist/daino-notes-public. I thought I might share some additional features I implemented.

  • Backward selection
  • Word selection (double click)
  • Line selection (triple click)
  • Smooth (accelerated) scrolling when selection is near the top/bottom of the view.
  • Some small improvements like hiding cursor on selection, handling selection outside of delegate.

Note:

  • I converted the delegate from RichText to PlainText in order to get a clean string of the text (not sure how to do it purely in QML, but I'm sure it's possible with the help of a C++ function) in selectLineAtPos() function.
  • Ofcourse, it's always better to save the sate inside the model data. I kept your solution since it's still works very nicely for a simple program and the state is not saved inside the delegates but in selectionArea that tells the delegates wether to be selected when they are rendered into view.

Still not implemented (I plan to implment these in my note-taking app):

  • Copy and paste
  • Undo/Redo
  • Select All
  • Arrow keys (up and down works great due to keyNavigationEnabled, but still need to implement when the user moves the cursor left and right from the start/end respectively.

Thanks again, and I hope this can be useful for others.

@shaan7 shaan7 changed the base branch from main to improvements/v1 August 18, 2023 13:59
@shaan7
Copy link
Copy Markdown
Owner

shaan7 commented Aug 18, 2023

Hi @nuttyartist , thanks for the PR! I am merging this to a separate branch since the code in main serves as an example to the talk which is still online.

@shaan7 shaan7 merged commit f503d79 into shaan7:improvements/v1 Aug 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants