mirror of
https://code.gri.mw/GUI/grim.git
synced 2026-07-11 17:28:55 +00:00
ui: reset keyboard window state on opening and inputs focus change
This commit is contained in:
@@ -141,6 +141,10 @@ impl<Platform: PlatformCallbacks> App<Platform> {
|
||||
if keyboard_showing {
|
||||
ctx.move_to_top(LayerId::new(Order::Middle, egui::Id::new(KeyboardContent::WINDOW_ID)));
|
||||
}
|
||||
// Reset keyboard state for newly opened modal.
|
||||
if Modal::first_draw() {
|
||||
KeyboardContent::reset_window_state();
|
||||
}
|
||||
}
|
||||
|
||||
/// Draw custom desktop window frame content.
|
||||
|
||||
@@ -149,6 +149,11 @@ impl TextEdit {
|
||||
text_edit_resp.request_focus();
|
||||
}
|
||||
|
||||
// Reset keyboard state for newly focused.
|
||||
if clicked || self.focus_request {
|
||||
KeyboardContent::reset_window_state();
|
||||
}
|
||||
|
||||
// Apply text from software input.
|
||||
if text_edit_resp.has_focus() {
|
||||
ui.data_mut(|data| {
|
||||
|
||||
@@ -499,4 +499,11 @@ impl KeyboardContent {
|
||||
let r_state = WINDOW_STATE.read();
|
||||
r_state.shift.store(false, Ordering::Relaxed);
|
||||
}
|
||||
|
||||
/// Reset keyboard window state.
|
||||
pub fn reset_window_state() {
|
||||
let mut w_state = WINDOW_STATE.write();
|
||||
w_state.layout = Arc::new(KeyboardLayout::TEXT);
|
||||
// *w_state = KeyboardState::default();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user