LibWeb: Add a hook for when an URL is dropped on an HtmlView

Embedders of HtmlView can now react to this by hooking on_url_drop.
This commit is contained in:
Andreas Kling 2020-05-10 21:03:37 +02:00
parent f1708b3832
commit fc26aefe81
Notes: sideshowbarker 2024-07-19 06:44:53 +09:00
2 changed files with 14 additions and 0 deletions

View file

@ -27,6 +27,7 @@
#include <AK/FileSystemPath.h>
#include <AK/URL.h>
#include <LibCore/File.h>
#include <LibCore/MimeData.h>
#include <LibGUI/Application.h>
#include <LibGUI/Painter.h>
#include <LibGUI/ScrollBar.h>
@ -590,4 +591,15 @@ void HtmlView::run_javascript_url(const String& url)
document()->run_javascript(source);
}
void HtmlView::drop_event(GUI::DropEvent& event)
{
if (event.mime_data().has_urls()) {
if (on_url_drop) {
on_url_drop(event.mime_data().urls().first());
return;
}
}
ScrollableWidget::drop_event(event);
}
}