MCPcopy Create free account
hub / github.com/DISTRHO/DPF / mouseEvent

Function mouseEvent

dgl/src/EventHandlers.cpp:54–104  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

52 lastMotionPos(0, 0) {}
53
54 bool mouseEvent(const Widget::MouseEvent& ev)
55 {
56 if (! enabledInput)
57 return false;
58
59 lastClickPos = ev.pos;
60
61 // button was released, handle it now
62 if (button != -1 && ! ev.press)
63 {
64 DISTRHO_SAFE_ASSERT(state & kButtonStateActive);
65
66 // release button
67 const int button2 = button;
68 button = -1;
69
70 const int state2 = state;
71 state &= ~kButtonStateActive;
72
73 self->stateChanged(static_cast<State>(state), static_cast<State>(state2));
74 widget->repaint();
75
76 // cursor was moved outside the button bounds, ignore click
77 if (! widget->contains(ev.pos))
78 return true;
79
80 // still on bounds, register click
81 if (checkable)
82 checked = !checked;
83
84 if (internalCallback != nullptr)
85 internalCallback->buttonClicked(widget, button2);
86 else if (userCallback != nullptr)
87 userCallback->buttonClicked(widget, button2);
88
89 return true;
90 }
91
92 // button was pressed, wait for release
93 if (ev.press && widget->contains(ev.pos))
94 {
95 const int state2 = state;
96 button = static_cast<int>(ev.button);
97 state |= kButtonStateActive;
98 self->stateChanged(static_cast<State>(state), static_cast<State>(state2));
99 widget->repaint();
100 return true;
101 }
102
103 return false;
104 }
105
106 bool motionEvent(const Widget::MotionEvent& ev)
107 {

Callers 3

onMouseMethod · 0.85
onMouseFunction · 0.85
onMouseMethod · 0.85

Calls 3

stateChangedMethod · 0.45
repaintMethod · 0.45
containsMethod · 0.45

Tested by

no test coverage detected