/** * @brief Handles selectboxes clicks */ static void UI_SelectBoxNodeClick (uiNode_t *node, int x, int y) { uiNode_t* option; int clickedAtOption; vec2_t pos; /* dropdown the node */ if (UI_GetMouseCapture() == NULL) { UI_SetMouseCapture(node); return; } UI_GetNodeAbsPos(node, pos); clickedAtOption = (y - pos[1]); /* we click outside */ if (x < pos[0] || y < pos[1] || x >= pos[0] + node->size[0] || y >= pos[1] + node->size[1] * (EXTRADATA(node).count + 1)) { UI_MouseRelease(); return; } /* we click on the head */ if (clickedAtOption < node->size[1]) { UI_MouseRelease(); return; } clickedAtOption = (clickedAtOption - node->size[1]) / node->size[1]; if (clickedAtOption < 0 || clickedAtOption >= EXTRADATA(node).count) return; if (UI_AbstractOptionGetCurrentValue(node) == NULL) return; /* select the right option */ option = UI_AbstractOptionGetFirstOption(node); for (; option; option = option->next) { if (option->invis) continue; if (clickedAtOption == 0) break; clickedAtOption--; } /* update the status */ if (option) UI_AbstractOptionSetCurrentValue(node, OPTIONEXTRADATA(option).value); /* close the dropdown */ UI_MouseRelease(); }
/** * @brief Called by the client when the user type a key * @param[in] key key code, either K_ value or lowercase ascii * @param[in] unicode translated meaning of keypress in unicode * @return true, if we used the event * @todo think about what we should do when the mouse is captured */ bool UI_KeyPressed (unsigned int key, unsigned short unicode) { int windowId; int lastWindowId; if (UI_DNDIsDragging()) { if (key == K_ESCAPE) UI_DNDAbort(); return false; } if (key == K_ESCAPE && CL_BattlescapeRunning() && selActor && CL_ActorFireModeActivated(selActor->actorMode)) { /* Cancel firing with Escape, needed for Android, where right mouse click is bound to multitouch, which is non-obvious */ CL_ActorSetMode(selActor, M_MOVE); return true; } /* translate event into the node with focus */ if (focusNode && UI_Node_KeyPressed(focusNode, key, unicode)) { return true; } /* else use common behaviour */ switch (key) { case K_TAB: if (UI_FocusNextActionNode()) return true; break; case K_ENTER: case K_KP_ENTER: if (UI_FocusExecuteActionNode()) return true; break; case K_ESCAPE: if (UI_GetMouseCapture() != nullptr) { UI_MouseRelease(); return true; } UI_PopWindowWithEscKey(); return true; } lastWindowId = UI_GetLastFullScreenWindow(); if (lastWindowId < 0) return false; /* check "active" window from top to down */ for (windowId = ui_global.windowStackPos - 1; windowId >= lastWindowId; windowId--) { const uiNode_t* window = ui_global.windowStack[windowId]; if (!window) return false; if (UI_KeyPressedInWindow(key, window)) return true; if (UI_WindowIsModal(window)) break; } return false; }
/** * @brief Release all captured input (keyboard or mouse) */ void UI_ReleaseInput (void) { UI_RemoveFocus(); UI_MouseRelease(); if (UI_DNDIsDragging()) UI_DNDAbort(); }
void uiGeoscapeNode::onMouseUp (uiNode_t* node, int x, int y, int button) { if (mode != MODE_NULL) { UI_MouseRelease(); mode = MODE_NULL; } }
static void UI_ZoneNodeUp (uiNode_t *node, int x, int y, int button) { if (!EXTRADATA(node).repeat) return; if (button == K_MOUSE1) { UI_MouseRelease(); } }
void uiModelNode::onMouseUp (uiNode_t* node, int x, int y, int button) { if (button != K_MOUSE1) return; if (UI_GetMouseCapture() != node) return; UI_MouseRelease(); }
void uiContainerNode::onCapturedMouseMove (uiNode_t *node, int x, int y) { const int delta = abs(oldMouseX - x) + abs(oldMouseY - y); if (delta > 15) { UI_DNDDragItem(node, &(dragInfoIC->item)); UI_MouseRelease(); } }
void uiBaseInventoryNode::onCapturedMouseMove (uiNode_t* node, int x, int y) { const int delta = abs(oldMouseX - x) + abs(oldMouseY - y); if (delta > 15) { UI_DNDDragItem(node, dragInfoIC); UI_MouseRelease(); } }
static void UI_VScrollbarNodeMouseUp (uiNode_t *node, int x, int y, int button) { if (EXTRADATA(node).fullsize == 0 || EXTRADATA(node).fullsize < EXTRADATA(node).viewsize) return; if (button != K_MOUSE1) return; if (UI_GetMouseCapture() == node) { UI_MouseRelease(); } }
void uiBaseInventoryNode::onMouseUp (uiNode_t* node, int x, int y, int button) { if (button != K_MOUSE1) return; if (UI_GetMouseCapture() == node) { UI_MouseRelease(); } if (UI_DNDIsDragging()) { UI_DNDDrop(); } }
/** * @brief Called by the client when the user type a key * @param[in] key key code, either K_ value or lowercase ascii * @param[in] unicode translated meaning of keypress in unicode * @return true, if we used the event * @todo think about what we should do when the mouse is captured */ bool UI_KeyPressed (unsigned int key, unsigned short unicode) { int windowId; int lastWindowId; if (UI_DNDIsDragging()) { if (key == K_ESCAPE) UI_DNDAbort(); return false; } /* translate event into the node with focus */ if (focusNode && UI_Node_KeyPressed(focusNode, key, unicode)) { return true; } /* else use common behaviour */ switch (key) { case K_TAB: if (UI_FocusNextActionNode()) return true; break; case K_ENTER: case K_KP_ENTER: if (UI_FocusExecuteActionNode()) return true; break; case K_ESCAPE: if (UI_GetMouseCapture() != NULL) { UI_MouseRelease(); return true; } UI_PopWindowWithEscKey(); return true; } lastWindowId = UI_GetLastFullScreenWindow(); if (lastWindowId < 0) return false; /* check "active" window from top to down */ for (windowId = ui_global.windowStackPos - 1; windowId >= lastWindowId; windowId--) { const uiNode_t *window = ui_global.windowStack[windowId]; if (!window) return false; if (UI_KeyPressedInWindow(key, window)) return true; if (UI_WindowIsModal(window)) break; } return false; }
void uiEditorNode::onMouseDown (uiNode_t* node, int x, int y, int button) { uiNode_t* hovered; if (UI_GetMouseCapture() != node) return; if (button != K_MOUSE1) return; hovered = UI_GetNodeAtPosition(mousePosX, mousePosY); /* stop the capture */ if (hovered && hovered->root == node->root) { UI_MouseRelease(); return; } if (hovered == anchoredNode) hovered = nullptr; if (anchoredNode) { dragStatus = UI_EditorNodeGetElementAtPosition(anchoredNode, x, y); if (dragStatus == ZONE_BODY) { if (hovered == nullptr) { startX = x; startY = y; return; } } else if (dragStatus != ZONE_NONE) { startX = x; startY = y; return; } } /* select the node */ UI_EditorNodeSelectNode(node, hovered); }
static void UI_OptionListNodeMouseUp (struct uiNode_s *node, int x, int y, int button) { if (UI_GetMouseCapture() == node) /* More checks can never hurt */ UI_MouseRelease(); }
static void UI_ControlsNodeMouseUp (uiNode_t *node, int x, int y, int button) { if (button == K_MOUSE1) UI_MouseRelease(); }
void uiRadarNode::onMouseUp (uiNode_t* node, int x, int y, int button) { if (button == K_MOUSE1) UI_MouseRelease(); }
static void UI_EditorNodeStop (uiNode_t* node, const uiCallContext_t* context) { UI_MouseRelease(); }
void uiOptionListNode::onMouseUp (uiNode_t* node, int x, int y, int button) { if (UI_GetMouseCapture() == node) /* More checks can never hurt */ UI_MouseRelease(); }
void uiSpinnerNode::onMouseUp (uiNode_t *node, int x, int y, int button) { if (button == K_MOUSE1 && UI_GetMouseCapture() == node) { UI_MouseRelease(); } }