mirror of
https://github.com/RGBCube/serenity
synced 2025-06-01 07:48:12 +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/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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue