Skip to content

Commit

Permalink
struct field rename => touching to slightly less bad last_touched
Browse files Browse the repository at this point in the history
  • Loading branch information
Ivy committed Apr 29, 2024
1 parent c7845fa commit abd713f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions src/systems.rs
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ pub fn process_input_system(
match VIRTUAL_KEYBOARD_GLOBAL.lock() {
Ok(mut touch_info) => {
touch_info.editing_text = editing_text;
touch_info.touching = true;
touch_info.last_touched = true;
}
Err(poisoned) => {
let _unused = poisoned.into_inner();
Expand Down Expand Up @@ -419,7 +419,7 @@ pub fn process_input_system(
match VIRTUAL_KEYBOARD_GLOBAL.lock() {
Ok(mut touch_info) => {
touch_info.editing_text = editing_text;
touch_info.touching = true;
touch_info.last_touched = true;
}
Err(poisoned) => {
let _unused = poisoned.into_inner();
Expand All @@ -439,7 +439,7 @@ pub fn process_input_system(
match VIRTUAL_KEYBOARD_GLOBAL.lock() {
Ok(mut touch_info) => {
touch_info.editing_text = editing_text;
touch_info.touching = true;
touch_info.last_touched = true;
}
Err(poisoned) => {
let _unused = poisoned.into_inner();
Expand All @@ -465,7 +465,7 @@ pub fn process_input_system(
match VIRTUAL_KEYBOARD_GLOBAL.lock() {
Ok(mut touch_info) => {
touch_info.editing_text = editing_text;
touch_info.touching = false;
touch_info.last_touched = false;
}
Err(poisoned) => {
let _unused = poisoned.into_inner();
Expand Down
8 changes: 4 additions & 4 deletions src/text_agent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ static AGENT_ID: &str = "egui_text_agent";
#[derive(Clone, Copy, Debug, Default)]
pub struct VirtualTouchInfo {
pub editing_text: bool,
pub touching: bool,
pub last_touched: bool,
}

pub static VIRTUAL_KEYBOARD_GLOBAL: Lazy<Mutex<VirtualTouchInfo>> =
Expand Down Expand Up @@ -181,7 +181,7 @@ pub fn virtual_keyboard_handler() {
let closure = Closure::wrap(Box::new(move |_event: web_sys::TouchEvent| {
match VIRTUAL_KEYBOARD_GLOBAL.lock() {
Ok(touch_info) => {
update_text_agent(touch_info.editing_text, touch_info.touching);
update_text_agent(touch_info.editing_text, touch_info.last_touched);
}
Err(poisoned) => {
let _unused = poisoned.into_inner();
Expand All @@ -196,7 +196,7 @@ pub fn virtual_keyboard_handler() {
}

/// Focus or blur text agent to toggle mobile keyboard.
fn update_text_agent(editing_text: bool, touching: bool) {
fn update_text_agent(editing_text: bool, last_touched: bool) {
use web_sys::HtmlInputElement;

let window = match web_sys::window() {
Expand Down Expand Up @@ -226,7 +226,7 @@ fn update_text_agent(editing_text: bool, touching: bool) {
if editing_text {
let is_already_editing = input.hidden();

if is_already_editing && touching {
if is_already_editing && last_touched {
input.set_hidden(false);
match input.focus().ok() {
Some(_) => {}
Expand Down

0 comments on commit abd713f

Please sign in to comment.