Skip to content
Snippets Groups Projects
Commit 07c5bb7b authored by Philip Whitfield's avatar Philip Whitfield
Browse files

added file drop events

parent 191051ab
Branches
No related tags found
No related merge requests found
......@@ -87,6 +87,16 @@ void input::handle_events() {
return false;
});
_handle_events<path_drop_event>(path_drop, [&](auto& event) {
for (auto& callback : callbacks)
if (callback->on_path_drop_event)
if (callback->on_path_drop_event(event))
return true;
return false;
});
}
gamepad::gamepad(gamepad_id id) : id(id) {
......
......@@ -174,6 +174,17 @@ struct mouse_button_event {
bool released(mouse_button b) const { return action == action::release && button == b; }
};
struct path_drop_event{
using ref = path_drop_event const&;
using func = std::function<bool(ref)>;
using listeners = std::map<id, func>;
using list = std::vector<path_drop_event>;
id sender;
std::vector<std::string> files;
};
struct mouse_active_event {
using ref = mouse_active_event const&;
......@@ -199,6 +210,7 @@ struct input_callback {
mouse_move_event::func on_mouse_move_event;
mouse_button_event::func on_mouse_button_event;
mouse_active_event::func on_mouse_active_event;
path_drop_event::func on_path_drop_event;
};
template <typename T>
......@@ -217,6 +229,7 @@ struct input : id_obj {
input_events<mouse_move_event> mouse_move;
input_events<mouse_button_event> mouse_button;
input_events<mouse_active_event> mouse_active;
input_events<path_drop_event> path_drop;
void handle_events();
......
......@@ -228,6 +228,15 @@ void window::handle_message() {
if (window->input)
window->input->mouse_active.add({ window->get_id(), entered > 0 });
});
glfwSetDropCallback(handle, [](GLFWwindow* handle, i32 amt, const char** paths){
auto window = get_window(handle);
if(!window)
return;
if(window->input)
window->input->path_drop.add({window->get_id(), {paths, paths+amt}});
});
}
template <int attr>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment