MCPcopy Create free account
hub / github.com/OpenStarbound/OpenStarbound / sendInputEvent

Method sendInputEvent

source/windowing/StarPaneManager.cpp:195–268  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

193}
194
195bool PaneManager::sendInputEvent(InputEvent const& event) {
196 if (event.is<MouseMoveEvent>()) {
197 m_tooltipLastMousePos = *m_context->mousePosition(event);
198
199 for (auto const& layerPair : m_displayedPanes) {
200 for (auto const& panePair : layerPair.second) {
201 if (panePair.first->dragActive()) {
202 panePair.first->drag(*m_context->mousePosition(event));
203 return true;
204 }
205 }
206 }
207 }
208
209 if (event.is<MouseButtonDownEvent>()) {
210 m_tooltipShowTimer.reset();
211 if (m_activeTooltip) {
212 dismiss(m_activeTooltip);
213 m_activeTooltip.reset();
214 m_tooltipParentPane.reset();
215 m_tooltipShowTimer.reset();
216 }
217 }
218
219 if (event.is<MouseButtonUpEvent>()) {
220 for (auto const& layerPair : m_displayedPanes) {
221 for (auto const& panePair : layerPair.second) {
222 if (panePair.first->dragActive()) {
223 panePair.first->setDragActive(false, {});
224 return true;
225 }
226 }
227 }
228 }
229
230 // The gui close event can only be intercepted by a pane that has captured
231 // the keyboard otherwise it will always be used to close first before being
232 // a normal event. This is so a window can control its own closing if it
233 // really needs to (like the keybindings window).
234 if (event.is<KeyDownEvent>() && m_context->actions(event).contains(InterfaceAction::GuiClose)) {
235 if (auto top = topPane({PaneLayer::ModalWindow, PaneLayer::Window})) {
236 dismiss(top);
237 return true;
238 }
239 }
240
241 // If there is a pane that has captured the keyboard, keyboard events will
242 // ONLY be sent to it.
243 auto keyCapturePane = keyboardCapturedPane();
244 if (keyCapturePane && (event.is<KeyDownEvent>() || event.is<KeyUpEvent>() || event.is<TextInputEvent>()))
245 return keyCapturePane->sendEvent(event);
246
247 bool foundModal = false;
248 for (auto& layerPair : m_displayedPanes) {
249 for (auto const& panePair : copy(layerPair.second)) {
250 if (panePair.first->sendEvent(event)) {
251 if (event.is<MouseButtonDownEvent>())
252 layerPair.second.toFront(panePair.first);

Callers 3

handleInputEventMethod · 0.80
handleInputEventMethod · 0.80
handleInputEventMethod · 0.80

Calls 10

dragActiveMethod · 0.80
dragMethod · 0.80
setDragActiveMethod · 0.80
copyFunction · 0.50
mousePositionMethod · 0.45
resetMethod · 0.45
containsMethod · 0.45
actionsMethod · 0.45
sendEventMethod · 0.45
toFrontMethod · 0.45

Tested by

no test coverage detected