fix focus grab on response area

This commit is contained in:
yggverse 2024-10-16 18:15:06 +03:00
parent 42e91cdb7c
commit 5d63f49987
4 changed files with 6 additions and 18 deletions

View File

@ -280,9 +280,7 @@ impl Page {
let description = gformat!("{placeholder}");
// Make input form
input.use_default(uri, Some(&description), Some(1024));
input.show();
// @TODO hide
input.set_default(uri, Some(&description), Some(1024));
// Update meta
meta.borrow_mut().status = Some(status);

View File

@ -23,15 +23,11 @@ impl Input {
}
// Actions
pub fn use_default(&self, base: Uri, title: Option<&str>, size_limit: Option<usize>) {
pub fn set_default(&self, base: Uri, title: Option<&str>, size_limit: Option<usize>) {
self.widget
.update(Some(&Default::new_arc(base, title, size_limit).gobject()));
}
pub fn show(&self) {
self.widget.show();
}
// Getters
pub fn gobject(&self) -> &Clamp {
&self.widget.gobject()

View File

@ -11,6 +11,7 @@ use widget::Widget;
use gtk::{
gio::SimpleAction,
glib::{uuid_string_random, Uri, UriHideFlags},
prelude::WidgetExt,
Box,
};
use std::sync::Arc;
@ -23,7 +24,7 @@ pub struct Default {
impl Default {
// Construct
pub fn new_arc(base: Uri, title: Option<&str>, size_limit: Option<usize>) -> Arc<Self> {
// Init local action group
// Init local action
let action_update = Arc::new(SimpleAction::new(&uuid_string_random(), None));
// Init components
@ -51,6 +52,8 @@ impl Default {
}
});
widget.gobject().connect_realize(move |_| response.focus());
// Return activated struct
Arc::new(Self { widget })
}

View File

@ -19,15 +19,6 @@ impl Widget {
}
// Actions
pub fn show(&self) {
self.gobject.set_visible(true)
}
/* not in use
pub fn hide(&self) {
self.gobject.set_visible(false)
} */
pub fn update(&self, child: Option<&Box>) {
if child.is_some() {
self.gobject.set_child(child);