Calling set_ime_cursor_location

Currently passing the entire input area because it's easy. Not closing
the issue because the correct thing to do would be to constrain the
location to a smaller area on the current line (or the current line).

Refs #122
This commit is contained in:
Jonathan Johnson 2024-01-04 17:08:05 -08:00
parent 4dc5cb5cc4
commit a3e76f6472
No known key found for this signature in database
GPG key ID: A66D6A34D6620579
4 changed files with 20 additions and 2 deletions

4
Cargo.lock generated
View file

@ -738,9 +738,9 @@ dependencies = [
[[package]]
name = "figures"
version = "0.2.1"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "813f0f9e0ba0d378a8e2cd51df24dd724ba8fbc07baa3dd192813eeba407ea86"
checksum = "2c59ceec98cdba2db23e28e753cf7ff1e7e726d8655f3dce45f0e40820ae075e"
dependencies = [
"bytemuck",
"euclid",

View file

@ -55,6 +55,8 @@ image = { version = "0.24.7", features = ["png"] }
# kludgine = { path = "../kludgine" }
# [patch."https://github.com/khonsulabs/appit"]
# appit = { path = "../appit" }
# [patch."https://github.com/khonsulabs/figures"]
# figures = { path = "../figures" }
[profile.dev.package."*"]
opt-level = 2

View file

@ -1057,6 +1057,7 @@ where
if context.focused(false) {
context.set_ime_allowed(true);
context.set_ime_location(context.gfx.region());
context.set_ime_purpose(if info.masked {
ImePurpose::Password
} else {

View file

@ -120,6 +120,15 @@ pub trait PlatformWindowImplementation {
winit.set_ime_allowed(allowed);
}
}
/// Sets the location of the cursor.
fn set_ime_location(&self, location: Rect<Px>) {
if let Some(winit) = self.winit() {
winit.set_ime_cursor_area(
PhysicalPosition::from(location.origin),
PhysicalSize::from(location.size),
);
}
}
/// Sets the current [`Ime`] purpose.
///
@ -220,6 +229,8 @@ pub trait PlatformWindow {
/// Sets the current cursor icon to `cursor`.
fn set_cursor_icon(&mut self, cursor: CursorIcon);
/// Sets the location of the cursor.
fn set_ime_location(&self, location: Rect<Px>);
/// Sets whether [`Ime`] events should be enabled.
fn set_ime_allowed(&self, allowed: bool);
/// Sets the current [`Ime`] purpose.
@ -422,6 +433,10 @@ where
fn request_inner_size(&mut self, inner_size: Size<UPx>) {
self.window.request_inner_size(inner_size);
}
fn set_ime_location(&self, location: Rect<Px>) {
self.window.set_ime_location(location);
}
}
/// The attributes of a Cushy window.