void TiBasicEditor::sendKey(SDL_keysym k1) { SDLKey k=k1.sym; if (keyParser::isChar(k1)) { sendChar(keyParser::getChar(k1)); return; } if (_isInSpecialCommandsMenu) { switch (k) { case SDLK_RETURN: sendChar( _specialsCommandsMenu->getSelectedString()[0]); _isInSpecialCommandsMenu=false; reDisplay(); return; case SDLK_DELETE: _isInSpecialCommandsMenu=false; reDisplay(); return; default: _specialsCommandsMenu->sendKey(k1); } } else { switch (k) { case SDLK_DELETE: rmChar(); break; case SDLK_UP: changeLine(true); break; case SDLK_DOWN: changeLine(false); break; case SDLK_LEFT: changeCursorPos(true); break; case SDLK_RIGHT: changeCursorPos(false); break; case SDLK_RETURN: addLine(); break; case SDLK_LALT: _isInSpecialCommandsMenu=true; _specialsCommandsMenu->reDisplay(); break; } } }
void LLScrollbar::pageDown(S32 overlap) { if (mDocSize > mPageSize) { changeLine( mPageSize - overlap, TRUE ); } }
BOOL LLScrollbar::handleHScrollWheel(S32 x, S32 y, S32 clicks) { changeLine( clicks * mStepSize, TRUE ); return TRUE; }
BOOL LLScrollbar::handleHover(S32 x, S32 y, MASK mask) { // Note: we don't bother sending the event to the children (the arrow buttons) // because they'll capture the mouse whenever they need hover events. BOOL handled = FALSE; if( hasMouseCapture() ) { S32 height = getRect().getHeight(); S32 width = getRect().getWidth(); if( VERTICAL == mOrientation ) { // S32 old_pos = mThumbRect.mTop; S32 delta_pixels = y - mDragStartY; if( mOrigRect.mBottom + delta_pixels < SCROLLBAR_SIZE ) { delta_pixels = SCROLLBAR_SIZE - mOrigRect.mBottom - 1; } else if( mOrigRect.mTop + delta_pixels > height - SCROLLBAR_SIZE ) { delta_pixels = height - SCROLLBAR_SIZE - mOrigRect.mTop + 1; } mThumbRect.mTop = mOrigRect.mTop + delta_pixels; mThumbRect.mBottom = mOrigRect.mBottom + delta_pixels; S32 thumb_length = mThumbRect.getHeight(); S32 thumb_track_length = height - 2 * SCROLLBAR_SIZE; if( delta_pixels != mLastDelta || mDocChanged) { // Note: delta_pixels increases as you go up. mDocPos increases down (line 0 is at the top of the page). S32 usable_track_length = thumb_track_length - thumb_length; if( 0 < usable_track_length ) { S32 variable_lines = getDocPosMax(); S32 pos = mThumbRect.mTop; F32 ratio = F32(pos - SCROLLBAR_SIZE - thumb_length) / usable_track_length; S32 new_pos = llclamp( S32(variable_lines - ratio * variable_lines + 0.5f), 0, variable_lines ); // Note: we do not call updateThumbRect() here. Instead we let the thumb and the document go slightly // out of sync (less than a line's worth) to make the thumb feel responsive. changeLine( new_pos - mDocPos, FALSE ); } } mLastDelta = delta_pixels; } else { // Horizontal // S32 old_pos = mThumbRect.mLeft; S32 delta_pixels = x - mDragStartX; if( mOrigRect.mLeft + delta_pixels < SCROLLBAR_SIZE ) { delta_pixels = SCROLLBAR_SIZE - mOrigRect.mLeft - 1; } else if( mOrigRect.mRight + delta_pixels > width - SCROLLBAR_SIZE ) { delta_pixels = width - SCROLLBAR_SIZE - mOrigRect.mRight + 1; } mThumbRect.mLeft = mOrigRect.mLeft + delta_pixels; mThumbRect.mRight = mOrigRect.mRight + delta_pixels; S32 thumb_length = mThumbRect.getWidth(); S32 thumb_track_length = width - 2 * SCROLLBAR_SIZE; if( delta_pixels != mLastDelta || mDocChanged) { // Note: delta_pixels increases as you go up. mDocPos increases down (line 0 is at the top of the page). S32 usable_track_length = thumb_track_length - thumb_length; if( 0 < usable_track_length ) { S32 variable_lines = getDocPosMax(); S32 pos = mThumbRect.mLeft; F32 ratio = F32(pos - SCROLLBAR_SIZE) / usable_track_length; S32 new_pos = llclamp( S32(ratio * variable_lines + 0.5f), 0, variable_lines); // Note: we do not call updateThumbRect() here. Instead we let the thumb and the document go slightly // out of sync (less than a line's worth) to make the thumb feel responsive. changeLine( new_pos - mDocPos, FALSE ); } } mLastDelta = delta_pixels; } getWindow()->setCursor(UI_CURSOR_ARROW); lldebugst(LLERR_USER_INPUT) << "hover handled by " << getName() << " (active)" << llendl; handled = TRUE; } else { handled = childrenHandleMouseUp( x, y, mask ) != NULL; } // Opaque if( !handled ) { getWindow()->setCursor(UI_CURSOR_ARROW); lldebugst(LLERR_USER_INPUT) << "hover handled by " << getName() << " (inactive)" << llendl; handled = TRUE; } mDocChanged = FALSE; return handled; } // end handleHover
void LLScrollbar::onLineDownBtnPressed( const LLSD& data ) { changeLine( mStepSize, TRUE ); }
BOOL LLScrollbar::handleScrollWheel(S32 x, S32 y, S32 clicks) { BOOL handled = changeLine( clicks * mStepSize, TRUE ); return handled; }