slint-ui / slint

Slint is a declarative GUI toolkit to build native user interfaces for Rust, C++, or JavaScript apps.
https://slint.dev
Other
17.56k stars 603 forks source link

Better text editing support #474

Open ogoffart opened 3 years ago

ogoffart commented 3 years ago

Current implementation of text edition lack some feature

jacquetc commented 3 years ago

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 ?

tronical commented 3 years ago

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.

jacquetc commented 3 years ago

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.

wwsinsh commented 10 months ago

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

moolight-seashell commented 1 month ago

I would be great if this give more settings for overwrite like

and Rich text support would be cool as well, including

[edit srry] duplicate of https://github.com/slint-ui/slint/issues/2723

Enyium commented 1 month ago
  • [ ] enter text overwrite mode when pressing insert key

Maybe this should be opt-in as an app-level Slint setting. I think this could confuse users, not knowing how to revert the behavior that may have been switched to by accident.