add double click mouse event impl
This commit is contained in:
@@ -31,6 +31,12 @@ namespace sandbox
|
|||||||
|
|
||||||
void test_panel::on_event(VE::event e)
|
void test_panel::on_event(VE::event e)
|
||||||
{
|
{
|
||||||
|
if (e.m_type.type() == typeid(VE::event_type))
|
||||||
|
{
|
||||||
|
auto t = std::any_cast<VE::event_type>(e.m_type);
|
||||||
|
if (t == VE::event_type::MOUSE_BUTTON_DOUBLE_PRESSED) hack::log()("double");
|
||||||
|
if (t == VE::event_type::MOUSE_BUTTON_PRESSED) hack::log()("once");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ namespace VE
|
|||||||
KEY_REPEATE,
|
KEY_REPEATE,
|
||||||
|
|
||||||
MOUSE_BUTTON_PRESSED,
|
MOUSE_BUTTON_PRESSED,
|
||||||
|
MOUSE_BUTTON_DOUBLE_PRESSED,
|
||||||
MOUSE_BUTTON_RELEASED,
|
MOUSE_BUTTON_RELEASED,
|
||||||
|
|
||||||
MOUSE_CURSOR_POSITION,
|
MOUSE_CURSOR_POSITION,
|
||||||
|
|||||||
@@ -163,7 +163,16 @@ namespace VE
|
|||||||
{
|
{
|
||||||
case GLFW_PRESS:
|
case GLFW_PRESS:
|
||||||
{
|
{
|
||||||
e.m_type = event_type::MOUSE_BUTTON_PRESSED;
|
static auto time = std::chrono::high_resolution_clock::now();
|
||||||
|
auto local = std::chrono::high_resolution_clock::now();
|
||||||
|
std::chrono::duration<double, std::milli> duration = local - time;
|
||||||
|
|
||||||
|
if (duration.count() > 10 && duration.count() < 200)
|
||||||
|
e.m_type = event_type::MOUSE_BUTTON_DOUBLE_PRESSED;
|
||||||
|
else
|
||||||
|
e.m_type = event_type::MOUSE_BUTTON_PRESSED;
|
||||||
|
|
||||||
|
time = local;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case GLFW_RELEASE:
|
case GLFW_RELEASE:
|
||||||
|
|||||||
Reference in New Issue
Block a user