QuantumBadger / Speedy2D

Rust library for hardware accelerated drawing of 2D shapes, images, and text, with an easy to use API.
Apache License 2.0
386 stars 42 forks source link

No support for ascii input (è, +, } etc...) #85

Closed dennisorlando closed 1 year ago

dennisorlando commented 1 year ago

Hi, I'm trying to get a simple text editor working but it appears to be very challenging given that VirtualKeyCode doesn't include all the characters and that the "KeyScancode to Ascii code" problem appears to be a problem which there are no libraries for (I literally can't find anything on the internet other than open issues and hardcoded maps). It appears that this issue also propagates to winit and glutin; is there any way to solve this?

Possible things that might be worth looking into:

dennisorlando commented 1 year ago

there's the "lapce" text editor written in rust that appears to be using the "druid" library

superlou commented 1 year ago

there's the "lapce" text editor written in rust that appears to be using the "druid" library

I think lapce is migrating to a custom framework called Floem, which is based on the Xilem architecture.

QuantumBadger commented 1 year ago

I think the callback you're looking for is on_keyboard_char -- this gives you the Unicode codepoint of which key was pressed, for the purpose of text entry.

on_key_up and on_key_down are aimed at things like games, where you want to know when a specific keyboard key was pressed/released, so these shouldn't be used for text entry.

dennisorlando commented 1 year ago

I think the callback you're looking for is on_keyboard_char -- this gives you the Unicode codepoint of which key was pressed, for the purpose of text entry.

on_key_up and on_key_down are aimed at things like games, where you want to know when a specific keyboard key was pressed/released, so these shouldn't be used for text entry.

oh, there it is! Works like a charm, thanks