mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 06:37:35 +00:00
HackStudio: Allow users to drag and drop files into the editor
This commit is contained in:
parent
2c93123daf
commit
21ecd5b804
2 changed files with 19 additions and 0 deletions
|
@ -40,6 +40,7 @@
|
||||||
#include <LibGUI/GMLSyntaxHighlighter.h>
|
#include <LibGUI/GMLSyntaxHighlighter.h>
|
||||||
#include <LibGUI/INISyntaxHighlighter.h>
|
#include <LibGUI/INISyntaxHighlighter.h>
|
||||||
#include <LibGUI/Label.h>
|
#include <LibGUI/Label.h>
|
||||||
|
#include <LibGUI/MessageBox.h>
|
||||||
#include <LibGUI/Painter.h>
|
#include <LibGUI/Painter.h>
|
||||||
#include <LibGUI/ScrollBar.h>
|
#include <LibGUI/ScrollBar.h>
|
||||||
#include <LibGUI/Window.h>
|
#include <LibGUI/Window.h>
|
||||||
|
@ -302,6 +303,23 @@ void Editor::mousedown_event(GUI::MouseEvent& event)
|
||||||
GUI::TextEditor::mousedown_event(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)
|
void Editor::enter_event(Core::Event& event)
|
||||||
{
|
{
|
||||||
m_hovering_editor = true;
|
m_hovering_editor = true;
|
||||||
|
|
|
@ -80,6 +80,7 @@ private:
|
||||||
virtual void paint_event(GUI::PaintEvent&) override;
|
virtual void paint_event(GUI::PaintEvent&) override;
|
||||||
virtual void mousemove_event(GUI::MouseEvent&) override;
|
virtual void mousemove_event(GUI::MouseEvent&) override;
|
||||||
virtual void mousedown_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 enter_event(Core::Event&) override;
|
||||||
virtual void leave_event(Core::Event&) override;
|
virtual void leave_event(Core::Event&) override;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue