diff --git a/examples/button.c b/examples/button.c index 0dac6ce..8bb7b24 100644 --- a/examples/button.c +++ b/examples/button.c @@ -8,22 +8,20 @@ static const float color_step = 10.0f; static PtkRect *r; -static void on_press(const int button, const int action, const int mods) { +static void on_press(const int button, const int mods) { (void)button; (void)mods; - if (action == GLFW_PRESS) { - PTK_DEBUG("pressed!"); - r->color.b += color_step / 255.0f; - if (r->color.b > 1.0f) { - r->color.b = 0.0f; + PTK_DEBUG("pressed!"); + r->color.b += color_step / 255.0f; + if (r->color.b > 1.0f) { + r->color.b = 0.0f; - r->color.g += color_step / 255.0f; - if (r->color.g > 1.0f) { - r->color.g = 0.0f; + r->color.g += color_step / 255.0f; + if (r->color.g > 1.0f) { + r->color.g = 0.0f; - r->color.r += color_step / 255.0f; - if (r->color.r > 1.0f) { - r->color.r = 0.0f; - } + r->color.r += color_step / 255.0f; + if (r->color.r > 1.0f) { + r->color.r = 0.0f; } } } diff --git a/include/ptk.h b/include/ptk.h index dc4bec6..c37a903 100644 --- a/include/ptk.h +++ b/include/ptk.h @@ -56,7 +56,7 @@ PTK_COMPONENT_DEFINE(PtkEllipse, PtkColor color; ); -typedef void (*MouseButtonCallback)(const int button, const int action, const int mods); +typedef void (*MouseButtonCallback)(const int button, const int mods); PTK_COMPONENT_DEFINE(PtkClickable, MouseButtonCallback on_press; diff --git a/src/ptk_vk/components.c b/src/ptk_vk/components.c index cc6ea40..57bdc2e 100644 --- a/src/ptk_vk/components.c +++ b/src/ptk_vk/components.c @@ -5,6 +5,8 @@ #include #include +#include + static PtkHandle m_root_component; static PTK_LIST(PtkHandle) m_components; @@ -171,6 +173,10 @@ bool intersects(const PtkHandle component, const PtkPos point) { } void vk_handle_mouse_button_input(const PtkPos cursor_pos, const int button, const int action, const int mods) { + if (action == GLFW_RELEASE) { + return; + } + for (size_t i = 0; i < m_components.size; ++i) { const PtkHandle current = m_components.data[i]; if (current->type != PTK_COMPONENT_TYPE_CLICKABLE) { @@ -180,7 +186,7 @@ void vk_handle_mouse_button_input(const PtkPos cursor_pos, const int button, con const PtkClickable *c = (PtkClickable *)current; if (intersects((PtkHandle)c, cursor_pos)) { - c->on_press(button, action, mods); + c->on_press(button, mods); vk_update_components(); } }