MCPcopy Create free account
hub / github.com/OpenApoc/OpenApoc / eventOccured

Method eventOccured

forms/listbox.cpp:147–187  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

145}
146
147void ListBox::eventOccured(Event *e)
148{
149 // ListBox does not pass mousedown and mouseup events when out of bounds
150 if ((e->type() != EVENT_MOUSE_DOWN && e->type() != EVENT_MOUSE_UP) || eventIsWithin(e))
151 {
152 Control::eventOccured(e);
153 }
154 if (e->type() == EVENT_FORM_INTERACTION)
155 {
156 sp<Control> ctrl = e->forms().RaisedBy;
157 sp<Control> child = ctrl->getAncestor(shared_from_this());
158 if (e->forms().EventFlag == FormEventType::MouseMove)
159 {
160 if (scroller && (ctrl == shared_from_this() || child != nullptr))
161 {
162 scroller->scrollWheel(e);
163 }
164 if (ctrl == shared_from_this() || ctrl == scroller)
165 {
166 child = nullptr;
167 }
168 if (hovered != child)
169 {
170 hovered = child;
171 this->pushFormEvent(FormEventType::ListBoxChangeHover, e);
172 }
173 }
174 else if (e->forms().EventFlag == FormEventType::MouseDown)
175 {
176 if (ctrl == shared_from_this() || ctrl == scroller || ctrl != child)
177 {
178 child = nullptr;
179 }
180 if (selected != child && child != nullptr)
181 {
182 selected = child;
183 this->pushFormEvent(FormEventType::ListBoxChangeSelected, e);
184 }
185 }
186 }
187}
188
189void ListBox::update()
190{

Callers

nothing calls this directly

Calls 4

typeMethod · 0.80
getAncestorMethod · 0.80
scrollWheelMethod · 0.80
pushFormEventMethod · 0.80

Tested by

no test coverage detected