diff options
-rw-r--r-- | Userland/DevTools/HackStudio/Editor.cpp | 18 | ||||
-rw-r--r-- | Userland/DevTools/HackStudio/Editor.h | 1 |
2 files changed, 19 insertions, 0 deletions
diff --git a/Userland/DevTools/HackStudio/Editor.cpp b/Userland/DevTools/HackStudio/Editor.cpp index 71f703d05d..e4b1c8bf74 100644 --- a/Userland/DevTools/HackStudio/Editor.cpp +++ b/Userland/DevTools/HackStudio/Editor.cpp @@ -40,6 +40,7 @@ #include <LibGUI/GMLSyntaxHighlighter.h> #include <LibGUI/INISyntaxHighlighter.h> #include <LibGUI/Label.h> +#include <LibGUI/MessageBox.h> #include <LibGUI/Painter.h> #include <LibGUI/ScrollBar.h> #include <LibGUI/Window.h> @@ -302,6 +303,23 @@ void Editor::mousedown_event(GUI::MouseEvent& event) GUI::TextEditor::mousedown_event(event); } +void Editor::drop_event(GUI::DropEvent& event) +{ + event.accept(); + window()->move_to_front(); + + if (event.mime_data().has_urls()) { + auto urls = event.mime_data().urls(); + if (urls.is_empty()) + return; + if (urls.size() > 1) { + GUI::MessageBox::show(window(), "HackStudio can only open one file at a time!", "One at a time please!", GUI::MessageBox::Type::Error); + return; + } + open_file(urls.first().path()); + } +} + void Editor::enter_event(Core::Event& event) { m_hovering_editor = true; diff --git a/Userland/DevTools/HackStudio/Editor.h b/Userland/DevTools/HackStudio/Editor.h index 588965bfc9..9343fa5e37 100644 --- a/Userland/DevTools/HackStudio/Editor.h +++ b/Userland/DevTools/HackStudio/Editor.h @@ -80,6 +80,7 @@ private: virtual void paint_event(GUI::PaintEvent&) override; virtual void mousemove_event(GUI::MouseEvent&) override; virtual void mousedown_event(GUI::MouseEvent&) override; + virtual void drop_event(GUI::DropEvent&) override; virtual void enter_event(Core::Event&) override; virtual void leave_event(Core::Event&) override; |