mirror of
https://code.gri.mw/GUI/grim.git
synced 2026-07-16 19:58:54 +00:00
ui: ability to not show soft keyboard for input, move modal on top only at first draw
This commit is contained in:
@@ -31,9 +31,6 @@ use crate::{AppConfig, Settings};
|
||||
lazy_static! {
|
||||
/// Global state to check if [`NetworkContent`] panel is open.
|
||||
static ref NETWORK_PANEL_OPEN: AtomicBool = AtomicBool::new(false);
|
||||
|
||||
/// Global state to check if [`NetworkContent`] panel is open.
|
||||
static ref SETTINGS_PANEL_OPEN: AtomicBool = AtomicBool::new(false);
|
||||
}
|
||||
|
||||
/// Contains main ui content, handles side panel state.
|
||||
|
||||
@@ -23,27 +23,29 @@ use crate::gui::views::{KeyboardEvent, View};
|
||||
/// Text input content.
|
||||
pub struct TextEdit {
|
||||
/// View identifier.
|
||||
pub id: egui::Id,
|
||||
id: egui::Id,
|
||||
/// Check if horizontal centering is needed.
|
||||
pub h_center: bool,
|
||||
h_center: bool,
|
||||
/// Check if focus is needed.
|
||||
pub focus: bool,
|
||||
focus: bool,
|
||||
/// Check if focus request was passed.
|
||||
focus_request: bool,
|
||||
/// Hide letters and draw button to show/hide letters.
|
||||
pub password: bool,
|
||||
password: bool,
|
||||
/// Show copy button.
|
||||
pub copy: bool,
|
||||
copy: bool,
|
||||
/// Show paste button.
|
||||
pub paste: bool,
|
||||
paste: bool,
|
||||
/// Show button to scan QR code into text.
|
||||
pub scan_qr: bool,
|
||||
scan_qr: bool,
|
||||
/// Callback when scan button was pressed.
|
||||
pub scan_pressed: bool,
|
||||
/// Callback when Enter key was pressed.
|
||||
pub enter_pressed: bool,
|
||||
/// Flag to enter only numbers.
|
||||
pub numeric: bool,
|
||||
numeric: bool,
|
||||
/// Flag to not show soft keyboard.
|
||||
no_soft_keyboard: bool,
|
||||
}
|
||||
|
||||
impl TextEdit {
|
||||
@@ -63,6 +65,7 @@ impl TextEdit {
|
||||
scan_pressed: false,
|
||||
enter_pressed: false,
|
||||
numeric: false,
|
||||
no_soft_keyboard: false,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -161,7 +164,9 @@ impl TextEdit {
|
||||
if self.enter_pressed {
|
||||
KeyboardContent::unshift();
|
||||
}
|
||||
KeyboardContent::default().window_ui(self.numeric, ui.ctx());
|
||||
if !self.no_soft_keyboard {
|
||||
KeyboardContent::default().window_ui(self.numeric, ui.ctx());
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -302,4 +307,10 @@ impl TextEdit {
|
||||
self.scan_pressed = false;
|
||||
self
|
||||
}
|
||||
|
||||
/// Do not show soft keyboard for input.
|
||||
pub fn no_soft_keyboard(mut self) -> Self {
|
||||
self.no_soft_keyboard = true;
|
||||
self
|
||||
}
|
||||
}
|
||||
@@ -248,12 +248,12 @@ impl Modal {
|
||||
}
|
||||
self.content_ui(ui, add_content);
|
||||
}).unwrap().response.layer_id;
|
||||
|
||||
// Always show main content window above background window.
|
||||
ctx.move_to_top(layer_id);
|
||||
|
||||
// Setup first draw flag.
|
||||
if Self::first_draw() {
|
||||
// Always show main content window above background window.
|
||||
ctx.move_to_top(layer_id);
|
||||
|
||||
let r_state = MODAL_STATE.read();
|
||||
let modal = r_state.modal.as_ref().unwrap();
|
||||
modal.first_draw.store(false, Ordering::Relaxed);
|
||||
|
||||
@@ -160,6 +160,7 @@ impl TransportSettingsModal {
|
||||
.with(wallet.get_config().id)
|
||||
.with("_bin_edit");
|
||||
let mut bin_edit = TextEdit::new(bin_edit_id)
|
||||
.no_soft_keyboard()
|
||||
.paste()
|
||||
.focus(false);
|
||||
let bin_edit_before = self.bridge_bin_path_edit.clone();
|
||||
@@ -178,6 +179,7 @@ impl TransportSettingsModal {
|
||||
.with(wallet.get_config().id)
|
||||
.with("_conn_edit");
|
||||
let mut conn_edit = TextEdit::new(conn_edit_id)
|
||||
.no_soft_keyboard()
|
||||
.paste()
|
||||
.focus(false)
|
||||
.scan_qr();
|
||||
|
||||
Reference in New Issue
Block a user