Add file drop functionality

Adds the ability to drag and drop files from windows in order to attempt
to execute them
This commit is contained in:
Leighton Hancock
2016-11-14 16:50:58 +13:00
parent f5168c5768
commit 524ba0c88c
7 changed files with 51 additions and 0 deletions

View File

@@ -32,6 +32,7 @@ using xe::ui::KeyEvent;
using xe::ui::MenuItem;
using xe::ui::MouseEvent;
using xe::ui::UIEvent;
using xe::ui::FileDropEvent;
const std::wstring kBaseTitle = L"xenia";
@@ -81,6 +82,9 @@ bool EmulatorWindow::Initialize() {
});
loop_->on_quit.AddListener([this](UIEvent* e) { window_.reset(); });
window_->on_file_drop.AddListener(
[this](FileDropEvent* e) { FileDrop(e->filename()); });
window_->on_key_down.AddListener([this](KeyEvent* e) {
bool handled = true;
switch (e->key_code()) {
@@ -257,6 +261,15 @@ bool EmulatorWindow::Initialize() {
return true;
}
void EmulatorWindow::FileDrop(wchar_t* filename) {
std::wstring path = filename;
auto result = emulator_->LaunchPath(path);
if (XFAILED(result)) {
// TODO: Display a message box.
XELOGE("Failed to launch target: %.8X", result);
}
}
void EmulatorWindow::FileOpen() {
std::wstring path;

View File

@@ -42,6 +42,7 @@ class EmulatorWindow {
bool Initialize();
void FileDrop(wchar_t* filename);
void FileOpen();
void CheckHideCursor();
void CpuTimeScalarReset();