summaryrefslogtreecommitdiff
path: root/Libraries/LibWeb
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-10-30 10:58:27 +0100
committerAndreas Kling <kling@serenityos.org>2020-10-30 17:03:28 +0100
commitaef56159a84a3e88422f7e7ebc11fe145ffe9075 (patch)
tree1ac8a8f2c652a2c3f0f9e39ff247e98909a09619 /Libraries/LibWeb
parent34014fa838cbc7e427ae00818fdf8f665f0e7801 (diff)
downloadserenity-aef56159a84a3e88422f7e7ebc11fe145ffe9075.zip
LibGUI: Add Widget focus policies
Every widget now has a GUI::FocusPolicy that determines how it can receive focus: - NoFocus: The widget is not focusable (default) - TabFocus: The widget can be focused using the tab key. - ClickFocus: The widget can be focused by clicking on it. - StrongFocus: Both of the above. For widgets that have a focus proxy, getting/setting the focus policy will affect the proxy instead.
Diffstat (limited to 'Libraries/LibWeb')
-rw-r--r--Libraries/LibWeb/InProcessWebView.cpp1
-rw-r--r--Libraries/LibWeb/InProcessWebView.h2
-rw-r--r--Libraries/LibWeb/OutOfProcessWebView.cpp1
-rw-r--r--Libraries/LibWeb/OutOfProcessWebView.h1
4 files changed, 2 insertions, 3 deletions
diff --git a/Libraries/LibWeb/InProcessWebView.cpp b/Libraries/LibWeb/InProcessWebView.cpp
index 983e3bb024..15dd3eb155 100644
--- a/Libraries/LibWeb/InProcessWebView.cpp
+++ b/Libraries/LibWeb/InProcessWebView.cpp
@@ -68,6 +68,7 @@ InProcessWebView::InProcessWebView()
{
set_should_hide_unnecessary_scrollbars(true);
set_background_role(ColorRole::Base);
+ set_focus_policy(GUI::FocusPolicy::StrongFocus);
m_copy_action = GUI::CommonActions::make_copy_action([this](auto&) {
GUI::Clipboard::the().set_plain_text(selected_text());
diff --git a/Libraries/LibWeb/InProcessWebView.h b/Libraries/LibWeb/InProcessWebView.h
index 6122e79f6a..e84778a2a5 100644
--- a/Libraries/LibWeb/InProcessWebView.h
+++ b/Libraries/LibWeb/InProcessWebView.h
@@ -61,8 +61,6 @@ public:
void set_should_show_line_box_borders(bool value) { m_should_show_line_box_borders = value; }
- virtual bool accepts_focus() const override { return true; }
-
GUI::Action& select_all_action() { return *m_select_all_action; }
GUI::Action& copy_action() { return *m_copy_action; }
diff --git a/Libraries/LibWeb/OutOfProcessWebView.cpp b/Libraries/LibWeb/OutOfProcessWebView.cpp
index ec62289ece..a8063092ac 100644
--- a/Libraries/LibWeb/OutOfProcessWebView.cpp
+++ b/Libraries/LibWeb/OutOfProcessWebView.cpp
@@ -40,6 +40,7 @@ namespace Web {
OutOfProcessWebView::OutOfProcessWebView()
{
set_should_hide_unnecessary_scrollbars(true);
+ set_focus_policy(GUI::FocusPolicy::StrongFocus);
m_client = WebContentClient::construct(*this);
client().post_message(Messages::WebContentServer::UpdateSystemTheme(Gfx::current_system_theme_buffer_id()));
}
diff --git a/Libraries/LibWeb/OutOfProcessWebView.h b/Libraries/LibWeb/OutOfProcessWebView.h
index 0633fd07f9..f610a40bdf 100644
--- a/Libraries/LibWeb/OutOfProcessWebView.h
+++ b/Libraries/LibWeb/OutOfProcessWebView.h
@@ -68,7 +68,6 @@ private:
OutOfProcessWebView();
// ^Widget
- virtual bool accepts_focus() const override { return true; }
virtual void paint_event(GUI::PaintEvent&) override;
virtual void resize_event(GUI::ResizeEvent&) override;
virtual void mousedown_event(GUI::MouseEvent&) override;