add tap event on iOS
This commit is contained in:
@@ -220,6 +220,7 @@ public:
|
||||
bool gesture_start(const glm::vec2& p0, const glm::vec2& p1);
|
||||
bool gesture_move(const glm::vec2& p0, const glm::vec2& p1);
|
||||
bool gesture_end();
|
||||
bool touch_tap(const glm::vec2& pos, int fingers, int tap_count);
|
||||
bool key_down(kKey key);
|
||||
bool key_up(kKey key);
|
||||
bool key_char(char key);
|
||||
|
||||
@@ -454,6 +454,18 @@ bool App::gesture_end()
|
||||
ret = main->on_event(&e);
|
||||
return ret == kEventResult::Consumed;
|
||||
}
|
||||
bool App::touch_tap(const glm::vec2& pos, int fingers, int tap_count)
|
||||
{
|
||||
redraw = true;
|
||||
TouchEvent e;
|
||||
e.m_type = kEventType::TouchTap;
|
||||
e.m_finger_count = fingers;
|
||||
e.m_tap_count = tap_count;
|
||||
kEventResult ret = kEventResult::Available;
|
||||
if (auto* main = layout[main_id])
|
||||
ret = main->on_event(&e);
|
||||
return ret == kEventResult::Consumed;
|
||||
}
|
||||
bool App::key_down(kKey key)
|
||||
{
|
||||
if (key == kKey::KeySpacebar && vr_active)
|
||||
|
||||
11
src/event.h
11
src/event.h
@@ -89,6 +89,7 @@ enum class kEventCategory : uint8_t
|
||||
KeyEvent,
|
||||
ButtonEvent,
|
||||
GestureEvent,
|
||||
TouchEvent,
|
||||
};
|
||||
|
||||
enum class kEventType : uint8_t
|
||||
@@ -107,6 +108,7 @@ enum class kEventType : uint8_t
|
||||
GestureStart,
|
||||
GestureMove,
|
||||
GestureEnd,
|
||||
TouchTap,
|
||||
KeyDown,
|
||||
KeyUp,
|
||||
KeyChar,
|
||||
@@ -158,3 +160,12 @@ public:
|
||||
glm::vec2 m_pos;
|
||||
glm::vec2 m_pos_delta;
|
||||
};
|
||||
|
||||
class TouchEvent : public Event
|
||||
{
|
||||
public:
|
||||
TouchEvent() { m_cat = kEventCategory::TouchEvent; }
|
||||
glm::vec2 m_pos;
|
||||
int m_finger_count;
|
||||
int m_tap_count;
|
||||
};
|
||||
|
||||
@@ -543,6 +543,7 @@ kEventResult NodeCanvas::handle_event(Event* e)
|
||||
MouseEvent* me = static_cast<MouseEvent*>(e);
|
||||
KeyEvent* ke = static_cast<KeyEvent*>(e);
|
||||
GestureEvent* ge = static_cast<GestureEvent*>(e);
|
||||
TouchEvent* te = static_cast<TouchEvent*>(e);
|
||||
auto loc = (me->m_pos - m_pos) * root()->m_zoom;
|
||||
|
||||
switch (e->m_type)
|
||||
@@ -631,6 +632,10 @@ kEventResult NodeCanvas::handle_event(Event* e)
|
||||
for (auto& mode : *m_canvas->m_mode)
|
||||
mode->on_GestureEvent(ge);
|
||||
break;
|
||||
case kEventType::TouchTap:
|
||||
if (te->m_finger_count == 2)
|
||||
ActionManager::undo();
|
||||
break;
|
||||
default:
|
||||
return kEventResult::Available;
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user