| 98 | } |
| 99 | |
| 100 | void Control::eventOccured(Event *e) |
| 101 | { |
| 102 | for (auto ctrlidx = Controls.rbegin(); ctrlidx != Controls.rend(); ctrlidx++) |
| 103 | { |
| 104 | auto c = *ctrlidx; |
| 105 | if (c->Visible && c->Enabled) |
| 106 | { |
| 107 | c->eventOccured(e); |
| 108 | if (e->Handled) |
| 109 | { |
| 110 | return; |
| 111 | } |
| 112 | } |
| 113 | } |
| 114 | |
| 115 | if (e->type() == EVENT_MOUSE_MOVE || e->type() == EVENT_MOUSE_DOWN || |
| 116 | e->type() == EVENT_MOUSE_UP || e->type() == EVENT_MOUSE_SCROLL) |
| 117 | { |
| 118 | bool newInside = isPointInsideControlBounds(e->mouse().X, e->mouse().Y); |
| 119 | // (e->mouse().X >= resolvedLocation.x && e->mouse().X < resolvedLocation.x + Size.x && |
| 120 | // e->mouse().Y >= resolvedLocation.y && e->mouse().Y < resolvedLocation.y + Size.y); |
| 121 | |
| 122 | if (e->type() == EVENT_MOUSE_MOVE || e->type() == EVENT_MOUSE_SCROLL) |
| 123 | { |
| 124 | if (newInside) |
| 125 | { |
| 126 | if (!mouseInside) |
| 127 | { |
| 128 | this->pushFormEvent(FormEventType::MouseEnter, e); |
| 129 | } |
| 130 | this->pushFormEvent(FormEventType::MouseMove, e); |
| 131 | e->Handled = true; |
| 132 | } |
| 133 | else |
| 134 | { |
| 135 | if (mouseInside) |
| 136 | { |
| 137 | this->pushFormEvent(FormEventType::MouseLeave, e); |
| 138 | mouseDepressed = false; |
| 139 | } |
| 140 | } |
| 141 | } |
| 142 | |
| 143 | if (e->type() == EVENT_MOUSE_DOWN) |
| 144 | { |
| 145 | if (newInside) |
| 146 | { |
| 147 | this->pushFormEvent(FormEventType::MouseDown, e); |
| 148 | mouseDepressed = true; |
| 149 | if (isClickable) |
| 150 | { |
| 151 | e->Handled = true; |
| 152 | } |
| 153 | } |
| 154 | } |
| 155 | |
| 156 | if (e->type() == EVENT_MOUSE_UP) |
| 157 | { |
nothing calls this directly
no test coverage detected