MCPcopy Create free account
hub / github.com/JACoders/OpenJK / Item_Bind_HandleKey

Function Item_Bind_HandleKey

code/ui/ui_shared.cpp:9523–9660  ·  view source on GitHub ↗

================= Item_Bind_HandleKey ================= */

Source from the content-addressed store, hash-verified

9521=================
9522*/
9523qboolean Item_Bind_HandleKey(itemDef_t *item, int key, qboolean down)
9524{
9525 int id;
9526 int i;
9527 menuDef_t *menu;
9528
9529 if (key == A_MOUSE1 && Rect_ContainsPoint(&item->window.rect, DC->cursorx, DC->cursory) && !g_waitingForKey)
9530 {
9531 if (down)
9532 {
9533 g_waitingForKey = qtrue;
9534 g_bindItem = item;
9535
9536 // Set all others in the menu to grey
9537 menu = (menuDef_t *) item->parent;
9538 for (i=0;i<menu->itemCount;++i)
9539 {
9540 if (menu->items[i] == item)
9541 {
9542 continue;
9543 }
9544 menu->items[i]->window.flags |= WINDOW_INACTIVE;
9545 }
9546
9547 }
9548 return qtrue;
9549 }
9550 else if (key == A_ENTER && !g_waitingForKey)
9551 {
9552 if (down)
9553 {
9554 g_waitingForKey = qtrue;
9555 g_bindItem = item;
9556
9557 // Set all others in the menu to grey
9558 menu = (menuDef_t *) item->parent;
9559 for (i=0;i<menu->itemCount;++i)
9560 {
9561 if (menu->items[i] == item)
9562 {
9563 continue;
9564 }
9565 menu->items[i]->window.flags |= WINDOW_INACTIVE;
9566 }
9567
9568 }
9569 return qtrue;
9570 }
9571 else
9572 {
9573 if (!g_waitingForKey || g_bindItem == NULL)
9574 {
9575 return qfalse;
9576 }
9577
9578 if (key & K_CHAR_FLAG)
9579 {
9580 return qtrue;

Callers 2

Item_HandleKeyFunction · 0.70
Menu_HandleKeyFunction · 0.70

Calls 4

Item_Bind_UngreyFunction · 0.85
Rect_ContainsPointFunction · 0.70
BindingIDFromNameFunction · 0.70
Controls_SetConfigFunction · 0.70

Tested by

no test coverage detected