slint icon indicating copy to clipboard operation
slint copied to clipboard

Better text editing support

Open ogoffart opened this issue 2 years ago • 4 comments

Current implementation of text edition lack some feature

  • [x] Shortcut like up and down
  • [ ] Shortcuts page up / page down
  • [x] select all text with ctrl+a
  • [x] more shortcut like ctrl+left/right/up/down and other shortcuts
  • [x] double click to select words / more clicks select lines
  • [x] on X11: middle click should paste
  • [x] clicking and selecting outside of the visible area should scroll properly
  • [ ] enter text overwrite mode when pressing insert key
  • [x] undo/redo (#4569)
  • [x] On wasm: show the virtual keyboard when focused
  • [x] #1467

ogoffart avatar Sep 06 '21 16:09 ogoffart

Hello, I just learned about the existence of .60, but I have a good-enough experience with Qt QML. Since .60 is influenced by the work done on QML language, I only want to point out that in Qt Quick's TextEdit and TextArea, the shortcuts PageUp and PageDown aren't implement too. Maybe there is a reason ? Managing shortcuts (Ctrl + xx) can be cumbersome when the code is meant to be a simple base. Also, maybe these shortcuts are different depending of the OS ? Same with the way a text is selected. Maybe some dev would want one day to color a word when double-clicking on it ? Imposing these behaviors is constricting the usage. I think it would be more beneficial to create a whole new widget, which would inheriting TextEdit. What do you think ?

jacquetc avatar Sep 10 '21 09:09 jacquetc

You're right that different platforms have slightly different shortcuts (for example cmd vs. control on macOS). IMO that should be handled transparently to the developer though, i.e. the primitive text input element should (and does) handle those.

There is the need for a way for developers to override shortcuts in the application code. That's a missing feature at the moment.

Note that implementation wise TextEdit is built on the TextInput and ScrollView right now. Such a composition could be done by hand if somebody wants to really fine-tune more aspects of the behavior.

tronical avatar Sep 10 '21 11:09 tronical

I know Qt is automatically switching Windows' Ctrl with OSx's Cmd keys. We code "Ctrl+X", it becomes "Cmd+X" on OSX without worrying about it. It's an interesting behavior, I think.

Undo/Redo would need to be a framework, independent from TextEdit. Qt's QUndoCommand with QUndoStack could be a good inspiration. I'm sorry to bring back Qt, but I am talking about what I know well. Surely that there are other/better ways to do Undo and I'm staying open. I'd love to help implement it.

jacquetc avatar Sep 10 '21 13:09 jacquetc

~~hello, I advice that it is necessary to add an attribute to determine whether the scroll bar automatically scrolls the latest content when the content exceeds the current display area.~~

-- I extracted that into a separate issue: #4290

wwsinsh avatar Dec 20 '23 06:12 wwsinsh