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