srctree

Robin Linden parent d03ac092 a68352c7
browser/gui: Map ctrl+L to focus the url input

inlinesplit
browser/gui/app.cpp added: 17, removed: 3, total 14
@@ -15,6 +15,7 @@
#include <fmt/format.h>
#include <imgui-SFML.h>
#include <imgui.h>
#include <imgui_internal.h>
#include <imgui_stdlib.h>
#include <spdlog/spdlog.h>
 
@@ -196,6 +197,13 @@ int App::run() {
scroll(event.key.shift ? 20 : 5);
break;
}
case sf::Keyboard::Key::L: {
if (!event.key.control) {
break;
}
focus_url_input();
break;
}
case sf::Keyboard::Key::F1: {
render_debug_ = !render_debug_;
break;
@@ -445,6 +453,11 @@ void App::run_overlay() {
ImGui::SFML::Update(window_, clock_.restart());
}
 
void App::focus_url_input() {
auto *window = ImGui::FindWindowByName("Navigation");
ImGui::ActivateItemByID(window->GetID("Url"));
}
 
void App::run_nav_widget() {
im::window("Navigation", {0, 0}, {window_.getSize().x / 2.f, 0}, [this] {
if (ImGui::InputText("Url", &url_buf_, ImGuiInputTextFlags_EnterReturnsTrue)) {
 
browser/gui/app.h added: 17, removed: 3, total 14
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2021-2022 Robin Lindén <dev@robinlinden.eu>
// SPDX-FileCopyrightText: 2021-2023 Robin Lindén <dev@robinlinden.eu>
//
// SPDX-License-Identifier: BSD-2-Clause
 
@@ -88,6 +88,7 @@ private:
void update_status_line();
 
void run_overlay();
void focus_url_input();
void run_nav_widget();
void run_http_response_widget() const;
void run_dom_widget() const;