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

Function Item_ListBox_HandleKey

code/ui/ui_shared.cpp:10174–10478  ·  view source on GitHub ↗

================= Item_ListBox_HandleKey ================= */

Source from the content-addressed store, hash-verified

10172=================
10173*/
10174qboolean Item_ListBox_HandleKey(itemDef_t *item, int key, qboolean down, qboolean force)
10175{
10176 listBoxDef_t *listPtr = (listBoxDef_t*)item->typeData;
10177 int count = DC->feederCount(item->special);
10178 int max, viewmax;
10179 if (force || (Rect_ContainsPoint(&item->window.rect, DC->cursorx, DC->cursory) && item->window.flags & WINDOW_HASFOCUS))
10180 {
10181 max = Item_ListBox_MaxScroll(item);
10182 if (item->window.flags & WINDOW_HORIZONTAL)
10183 {
10184 viewmax = (item->window.rect.w / listPtr->elementWidth);
10185 if ( key == A_CURSOR_LEFT || key == A_KP_4 )
10186 {
10187 if (!listPtr->notselectable)
10188 {
10189 listPtr->cursorPos--;
10190 if (listPtr->cursorPos < 0)
10191 {
10192 listPtr->cursorPos = 0;
10193 }
10194 if (listPtr->cursorPos < listPtr->startPos)
10195 {
10196 listPtr->startPos = listPtr->cursorPos;
10197 }
10198 if (listPtr->cursorPos >= listPtr->startPos + viewmax)
10199 {
10200 listPtr->startPos = listPtr->cursorPos - viewmax + 1;
10201 }
10202 item->cursorPos = listPtr->cursorPos;
10203
10204 DC->feederSelection(item->special, item->cursorPos, item);
10205
10206 }
10207 else
10208 {
10209 listPtr->startPos--;
10210 if (listPtr->startPos < 0)
10211 {
10212 listPtr->startPos = 0;
10213 }
10214 }
10215 return qtrue;
10216 }
10217 if ( key == A_CURSOR_RIGHT || key == A_KP_6 )
10218 {
10219 if (!listPtr->notselectable)
10220 {
10221 listPtr->cursorPos++;
10222
10223 if (listPtr->cursorPos < listPtr->startPos)
10224 {
10225 listPtr->startPos = listPtr->cursorPos;
10226 }
10227 if (listPtr->cursorPos >= count)
10228 {
10229 listPtr->cursorPos = count-1;
10230 }
10231 if (listPtr->cursorPos >= listPtr->startPos + viewmax)

Callers 3

Scroll_ListBox_AutoFuncFunction · 0.70
Scroll_ListBox_ThumbFuncFunction · 0.70
Item_HandleKeyFunction · 0.70

Calls 4

Rect_ContainsPointFunction · 0.70
Item_ListBox_MaxScrollFunction · 0.70
Display_MouseMoveFunction · 0.70
Item_RunScriptFunction · 0.70

Tested by

no test coverage detected