mirror of
https://github.com/YGGverse/Yoda.git
synced 2025-01-15 17:20:08 +00:00
add last focus value holder
This commit is contained in:
parent
07d952ea7e
commit
f900fa80b1
@ -54,17 +54,24 @@ impl Widget {
|
|||||||
action_page_reload.activate(None);
|
action_page_reload.activate(None);
|
||||||
});
|
});
|
||||||
|
|
||||||
gobject.connect_state_flags_changed(|this, state| {
|
gobject.connect_state_flags_changed({
|
||||||
// Select entire text on key release
|
// Define last focus state container
|
||||||
// this behavior implemented in most web-browsers,
|
let has_focus = RefCell::new(false);
|
||||||
// to simply overwrite current request with new value
|
move |this, state| {
|
||||||
// Note:
|
// Select entire text on first click release
|
||||||
// * Custom GestureClick is not option here, as GTK Entry already has default one
|
// this behavior implemented in most web-browsers,
|
||||||
if state.contains(StateFlags::ACTIVE | StateFlags::FOCUS_WITHIN) {
|
// to simply overwrite current request with new value
|
||||||
// Continue on first focus event
|
// Note:
|
||||||
if this.selection_bounds().is_none() {
|
// * Custom GestureClick is not an option here, as GTK Entry has default controller
|
||||||
|
// * This is experimental feature as does not follow native GTK behavior @TODO test
|
||||||
|
if !has_focus.take()
|
||||||
|
&& state.contains(StateFlags::ACTIVE | StateFlags::FOCUS_WITHIN)
|
||||||
|
&& this.selection_bounds().is_none()
|
||||||
|
{
|
||||||
this.select_region(0, this.text_length().into());
|
this.select_region(0, this.text_length().into());
|
||||||
}
|
}
|
||||||
|
// Update last focus state
|
||||||
|
has_focus.replace(state.contains(StateFlags::FOCUS_WITHIN));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user