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

Function Item_TextScroll_HandleKey

code/ui/ui_shared.cpp:8740–8878  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8738}
8739
8740qboolean Item_TextScroll_HandleKey ( itemDef_t *item, int key, qboolean down, qboolean force)
8741{
8742 textScrollDef_t *scrollPtr = (textScrollDef_t*)item->typeData;
8743 int max;
8744 int viewmax;
8745
8746 if (force || (Rect_ContainsPoint(&item->window.rect, DC->cursorx, DC->cursory) && item->window.flags & WINDOW_HASFOCUS))
8747 {
8748 max = Item_TextScroll_MaxScroll(item);
8749
8750 viewmax = (item->window.rect.h / scrollPtr->lineHeight);
8751 if ( key == A_CURSOR_UP || key == A_KP_8 )
8752 {
8753 scrollPtr->startPos--;
8754 if (scrollPtr->startPos < 0)
8755 {
8756 scrollPtr->startPos = 0;
8757 }
8758 return qtrue;
8759 }
8760
8761 if ( key == A_CURSOR_DOWN || key == A_KP_2 )
8762 {
8763 scrollPtr->startPos++;
8764 if (scrollPtr->startPos > max)
8765 {
8766 scrollPtr->startPos = max;
8767 }
8768
8769 return qtrue;
8770 }
8771
8772 //Raz: Added
8773 if ( key == A_MWHEELUP )
8774 {
8775 scrollPtr->startPos--;
8776 if (scrollPtr->startPos < 0)
8777 {
8778 scrollPtr->startPos = 0;
8779 Display_MouseMove(NULL, DC->cursorx, DC->cursory);
8780 return qfalse;
8781 }
8782 Display_MouseMove(NULL, DC->cursorx, DC->cursory);
8783 return qtrue;
8784 }
8785 if ( key == A_MWHEELDOWN )
8786 {
8787 scrollPtr->startPos++;
8788 if (scrollPtr->startPos > max)
8789 {
8790 scrollPtr->startPos = max;
8791 Display_MouseMove(NULL, DC->cursorx, DC->cursory);
8792 return qfalse;
8793 }
8794 Display_MouseMove(NULL, DC->cursorx, DC->cursory);
8795 return qtrue;
8796 }
8797

Callers 3

Item_HandleKeyFunction · 0.70

Calls 3

Rect_ContainsPointFunction · 0.70
Display_MouseMoveFunction · 0.70

Tested by

no test coverage detected