Closed rirze closed 1 year ago
Hi @rirze! Ideally this would be fully handled at the cosmic-text level, while glyphon is only responsible for the actual rendering.
It might be helpful to take a look at Action
in cosmic-text (https://github.com/pop-os/cosmic-text/blob/e7f3e161b4a3628c4db234df64f07dd470316585/src/edit/mod.rs#L61C1-L61C1) and how it's used in the examples in that repo.
I was looking at that and I got confused-- from the implementations in the examples (like the libcosmic-editor), the gui library gives an event that returns what line x,y has been selected. Now thinking about it further, is this something that should be handled at the gui framwork level (like iced)?
Sorry if this is all obvious, I'm trying wrap my head around where crates are utilized in the GUI stack...
Yeah definitely, a GUI crate like iced could handle it for you if you'd like to use something like that.
If you want to handle mouse events directly yourself (e.g., using a windowing crate like winit without a GUI crate), the rich-text example might be a good starting point https://github.com/pop-os/cosmic-text/blob/e7f3e161b4a3628c4db234df64f07dd470316585/examples/rich-text/src/main.rs The Editor
is part of cosmic-text in this case, and it's basically forwarding mouse events directly to that Editor
as a cosmic-text Action
.
That example seems to be using orbclient::Window
from what I can tell (window.events()
is returning orbclient events, I think...), and that's a GUI framework like iced
? Sorry, this became more of a noob asking questions rather than an actual project issue. At any point, feel free to turn this into a discussion or close the issue.
Thanks for your help again.
Hi,
I was wondering if there was a way to obtain (line, character) information from a rendered text area in a window? I can't think of another way to highlight words using the cursor, for example.
What would it take for such a calculation to be done?
Thanks.