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 604 forks source link

Change type of `text` in `WindowEvent` keyevent to `SharedString` #1749

Closed FloVanGH closed 1 year ago

FloVanGH commented 2 years ago

To prevent #1747 to introduce a braking change by using SharedString for key event text what make it necessary to remove Clone derive from WindowEvent, char will be used now. It should be replaced by SharedString for 0.4.

ogoffart commented 1 year ago

I used to think that keys cannot be represented by a char and therefore the keys should always be a string instead of a char. But i now have my doubts. Maybe char is actually enough?

Edit: Note that even if we keep char, we should remove the Copy bound because of future possible events such as compose events

tronical commented 1 year ago

Tobias was the last person to have input on this in the previous PR:

https://github.com/slint-ui/slint/pull/1747#issuecomment-1308448798 https://github.com/slint-ui/slint/pull/1747#issuecomment-1308543169

One compelling argument I see is that Apple went for a string as well: https://developer.apple.com/documentation/uikit/uikey/3526130-characters

hunger commented 1 year ago

A key can return more than one char. E.g. Ä has a compatibility encoding of one char Ä, but the official encoding is A followed by a two dots above character. Depending on system configuration a keyboard may return one or the other.