================= Item_ListBox_HandleKey ================= */
| 10172 | ================= |
| 10173 | */ |
| 10174 | qboolean 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) |
no test coverage detected