ime positioning
This commit is contained in:
@@ -41,7 +41,6 @@ impl ApplicationHandler<ClientEvent> for App {
|
|||||||
let window = event_loop
|
let window = event_loop
|
||||||
.create_window(Window::default_attributes())
|
.create_window(Window::default_attributes())
|
||||||
.unwrap();
|
.unwrap();
|
||||||
window.set_ime_allowed(true);
|
|
||||||
let client = Client::new(AppHandle {
|
let client = Client::new(AppHandle {
|
||||||
proxy: self.proxy.clone(),
|
proxy: self.proxy.clone(),
|
||||||
window: window.into(),
|
window: window.into(),
|
||||||
|
|||||||
@@ -130,6 +130,7 @@ impl Client {
|
|||||||
match text.apply_event(&event, &self.input.modifiers) {
|
match text.apply_event(&event, &self.input.modifiers) {
|
||||||
TextInputResult::Unfocus => {
|
TextInputResult::Unfocus => {
|
||||||
self.focus = None;
|
self.focus = None;
|
||||||
|
self.handle.window.set_ime_allowed(false);
|
||||||
}
|
}
|
||||||
TextInputResult::Submit => {
|
TextInputResult::Submit => {
|
||||||
self.run_event(sel, Submit, ());
|
self.run_event(sel, Submit, ());
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
use iris::prelude::*;
|
use iris::prelude::*;
|
||||||
use len_fns::*;
|
use len_fns::*;
|
||||||
|
use winit::dpi::{LogicalPosition, LogicalSize, PhysicalSize};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
client::Client,
|
client::Client,
|
||||||
@@ -61,7 +62,7 @@ fn login_screen(client: &mut Client) -> WidgetId {
|
|||||||
.clone()
|
.clone()
|
||||||
.pad(10)
|
.pad(10)
|
||||||
.background(rect(Color::BLACK.brighter(0.1)).radius(15))
|
.background(rect(Color::BLACK.brighter(0.1)).radius(15))
|
||||||
.on(CursorSense::click(), focus(field))
|
.on(CursorSense::click(), focus_other(field))
|
||||||
};
|
};
|
||||||
|
|
||||||
// I LAV NOT HAVING ERGONOMIC CLONES
|
// I LAV NOT HAVING ERGONOMIC CLONES
|
||||||
@@ -112,10 +113,7 @@ pub fn msg_widget(msg: Msg) -> impl WidgetLike<FnTag> {
|
|||||||
.size(20)
|
.size(20)
|
||||||
.text_align(Align::Left)
|
.text_align(Align::Left)
|
||||||
.wrap(true)
|
.wrap(true)
|
||||||
.id_on(CursorSense::click(), |id, client: &mut Client, ctx| {
|
.id_on(CursorSense::click(), |i, c, d| focus(i.clone(), c, d));
|
||||||
client.ui.text(id).select(ctx.cursor, ctx.size);
|
|
||||||
client.focus = Some(id.clone());
|
|
||||||
});
|
|
||||||
let header = text(msg.user).size(20);
|
let header = text(msg.user).size(20);
|
||||||
(
|
(
|
||||||
image(include_bytes!("./assets/sungals.png"))
|
image(include_bytes!("./assets/sungals.png"))
|
||||||
@@ -129,10 +127,21 @@ pub fn msg_widget(msg: Msg) -> impl WidgetLike<FnTag> {
|
|||||||
.gap(10)
|
.gap(10)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn focus(id: WidgetId<TextEdit>) -> impl Fn(&mut Client, CursorData) {
|
pub fn focus(id: WidgetId<TextEdit>, client: &mut Client, data: CursorData) {
|
||||||
|
client.ui.text(&id).select(data.cursor, data.size);
|
||||||
|
if let Some(region) = client.ui.window_region(&id) {
|
||||||
|
client.handle.window.set_ime_allowed(true);
|
||||||
|
client.handle.window.set_ime_cursor_area(
|
||||||
|
LogicalPosition::<f32>::from(region.top_left.tuple()),
|
||||||
|
LogicalSize::<f32>::from(region.size().tuple()),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
client.focus = Some(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn focus_other(id: WidgetId<TextEdit>) -> impl Fn(&mut Client, CursorData) {
|
||||||
move |client: &mut Client, data: CursorData| {
|
move |client: &mut Client, data: CursorData| {
|
||||||
client.ui.text(&id).select(data.cursor, data.size);
|
focus(id.clone(), client, data);
|
||||||
client.focus = Some(id.clone());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -163,7 +172,7 @@ pub fn msg_panel(client: &mut Client, network: NetSender) -> impl WidgetFn<Stack
|
|||||||
client.ui[&msg_area].children.push(msg.any());
|
client.ui[&msg_area].children.push(msg.any());
|
||||||
})
|
})
|
||||||
.pad(15)
|
.pad(15)
|
||||||
.on(CursorSense::click(), focus(send_text))
|
.on(CursorSense::click(), focus_other(send_text))
|
||||||
.background(rect(Color::BLACK.brighter(0.05)).radius(15))
|
.background(rect(Color::BLACK.brighter(0.05)).radius(15))
|
||||||
.pad(15)
|
.pad(15)
|
||||||
.height(80)
|
.height(80)
|
||||||
|
|||||||
Reference in New Issue
Block a user