| 164 | } |
| 165 | |
| 166 | void MultilistBox::eventOccured(Event *e) |
| 167 | { |
| 168 | // MultilistBox does not pass mousedown and mouseup events when out of bounds |
| 169 | if ((e->type() != EVENT_MOUSE_DOWN && e->type() != EVENT_MOUSE_UP) || eventIsWithin(e)) |
| 170 | { |
| 171 | Control::eventOccured(e); |
| 172 | } |
| 173 | if (e->type() == EVENT_FORM_INTERACTION) |
| 174 | { |
| 175 | sp<Control> ctrl = e->forms().RaisedBy; |
| 176 | sp<Control> child = ctrl->getAncestor(shared_from_this()); |
| 177 | |
| 178 | switch (e->forms().EventFlag) |
| 179 | { |
| 180 | case FormEventType::MouseMove: |
| 181 | if (scroller && (ctrl == shared_from_this() || child != nullptr)) |
| 182 | { |
| 183 | scroller->scrollWheel(e); |
| 184 | } |
| 185 | |
| 186 | // check hover |
| 187 | if (ctrl == shared_from_this() || ctrl == scroller || |
| 188 | !isPointInsideControlBounds(e, child)) |
| 189 | { |
| 190 | child = nullptr; |
| 191 | } |
| 192 | if (hoveredItem != child) |
| 193 | { |
| 194 | hoveredItem = child; |
| 195 | this->pushFormEvent(FormEventType::ListBoxChangeHover, e); |
| 196 | } |
| 197 | break; |
| 198 | |
| 199 | case FormEventType::MouseDown: |
| 200 | // don't want to use the MouseClick event because drag&drop will be bugged |
| 201 | // General concept: MouseDown - selection action; MouseUp - unselection, but not |
| 202 | // during one click. |
| 203 | if (ctrl == child && isPointInsideControlBounds(e, child) && ctrl != scroller) |
| 204 | { |
| 205 | selectedItem = child; |
| 206 | selectionAction = selectedSet.find(child) == selectedSet.end(); |
| 207 | if (selectionAction && funcHandleSelection(e, child, true)) |
| 208 | { |
| 209 | selectedSet.insert(child); |
| 210 | this->pushFormEvent(FormEventType::ListBoxChangeSelected, e); |
| 211 | } |
| 212 | } |
| 213 | break; |
| 214 | |
| 215 | case FormEventType::MouseUp: |
| 216 | if (ctrl == child && isPointInsideControlBounds(e, child) && ctrl != scroller) |
| 217 | { |
| 218 | // unselect only if it hasnt been selected during this click |
| 219 | if (!selectionAction && selectedItem == child && |
| 220 | selectedSet.find(child) != selectedSet.end() && |
| 221 | !funcHandleSelection(e, child, false)) |
| 222 | { |
| 223 | selectedSet.erase(child); |
nothing calls this directly
no test coverage detected