mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-20 19:45:12 +00:00
HackStudio: Allow users to drag and drop files into the editor
This commit is contained in:
parent
2c93123daf
commit
21ecd5b804
Notes:
sideshowbarker
2024-07-18 20:28:15 +09:00
Author: https://github.com/ry-sev 🔰 Commit: https://github.com/SerenityOS/serenity/commit/21ecd5b804b Pull-request: https://github.com/SerenityOS/serenity/pull/6247 Reviewed-by: https://github.com/itamar8910 ✅
2 changed files with 19 additions and 0 deletions
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue