1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-19 00:35:06 +00:00

WebContent: Plumb hovered links from WebContent process over to widget

Also add a little GUI::StatusBar to the demo app so we can see the
hovered link URL's live. :^)
This commit is contained in:
Andreas Kling 2020-07-05 16:59:20 +02:00
parent aac362b883
commit 58b1ba2545
8 changed files with 61 additions and 1 deletions

View file

@ -27,6 +27,8 @@
#include "WebContentView.h"
#include <AK/URL.h>
#include <LibGUI/Application.h>
#include <LibGUI/BoxLayout.h>
#include <LibGUI/StatusBar.h>
#include <LibGUI/Widget.h>
#include <LibGUI/Window.h>
@ -34,7 +36,11 @@ int main(int argc, char** argv)
{
auto app = GUI::Application::construct(argc, argv);
auto window = GUI::Window::construct();
auto& view = window->set_main_widget<WebContentView>();
auto& main_widget = window->set_main_widget<GUI::Widget>();
main_widget.set_fill_with_background_color(true);
main_widget.set_layout<GUI::VerticalBoxLayout>();
auto& view = main_widget.add<WebContentView>();
auto& statusbar = main_widget.add<GUI::StatusBar>();
window->set_title("WebView");
window->set_rect(100, 100, 640, 480);
window->show();
@ -43,6 +49,13 @@ int main(int argc, char** argv)
window->set_title(String::format("%s - WebView", title.characters()));
};
view.on_link_hover = [&](auto& url) {
if (url.is_valid())
statusbar.set_text(url.to_string());
else
statusbar.set_text("");
};
view.load("file:///res/html/misc/welcome.html");
return app->exec();