From ff3fb354b43579d8d70b36c788add9a294228a86 Mon Sep 17 00:00:00 2001 From: yggverse Date: Sat, 20 Jul 2024 17:08:08 +0300 Subject: [PATCH] set entry focus on tab init --- src/Entity/Browser/Container/Page.php | 25 +++++++++++++++++++++---- src/Entity/Browser/Container/Tab.php | 5 ++++- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/src/Entity/Browser/Container/Page.php b/src/Entity/Browser/Container/Page.php index d2515d6..f537968 100644 --- a/src/Entity/Browser/Container/Page.php +++ b/src/Entity/Browser/Container/Page.php @@ -95,12 +95,29 @@ class Page } public function init( - ?string $request = null + ?string $request = null, + bool $focus = false ): void { - $this->navbar->request->setValue( - $request - ); + if ($request) + { + $this->navbar->request->setValue( + $request + ); + } + + if ($focus) + { + \Gtk::timeout_add( + 100, + function() + { + $this->navbar->request->focus(); + + return false; + } + ); + } } public function open( diff --git a/src/Entity/Browser/Container/Tab.php b/src/Entity/Browser/Container/Tab.php index 374bed9..2322749 100644 --- a/src/Entity/Browser/Container/Tab.php +++ b/src/Entity/Browser/Container/Tab.php @@ -159,7 +159,10 @@ class Tab else { $page->init( - $request + $request, + empty( + $request + ) ); }