void GuiTextEditCtrl::onMouseDragged( const GuiEvent &event ) { S32 pos = calculateCursorPos( event.mousePoint ); // if the position is to the left if ( pos == -1 ) mScrollDir = -1; else if ( pos == -2 ) // the position is to the right mScrollDir = 1; else // set the new cursor position { mScrollDir = 0; mCursorPos = pos; } // update the block: mBlockStart = getMin( mCursorPos, mMouseDragStart ); mBlockEnd = getMax( mCursorPos, mMouseDragStart ); if ( mBlockStart < 0 ) mBlockStart = 0; if ( mBlockStart == mBlockEnd ) mBlockStart = mBlockEnd = 0; //let the parent get the event Parent::onMouseDragged(event); }
void GuiTextEditSliderCtrl::onMouseUp(const GuiEvent &event) { // If we're not active then skip out. if ( !mActive || !mAwake || !mVisible ) { Parent::onMouseUp(event); return; } mMulInc = 0.0f; mouseUnlock(); if ( mTextAreaHit != None ) selectAllText(); //if we released the mouse within this control, then the parent will call //the mConsoleCommand other wise we have to call it. Parent::onMouseUp(event); //if we didn't release the mouse within this control, then perform the action // if (!cursorInControl()) execConsoleCallback(); execAltConsoleCallback(); //Set the cursor position to where the user clicked mCursorPos = calculateCursorPos( event.mousePoint ); mTextAreaHit = None; }
void GuiTextEditCtrl::onMouseDown( const GuiEvent &event ) { if(!isActive()) return; mDragHit = false; // If we have a double click, select all text. Otherwise // act as before by clearing any selection. bool doubleClick = (event.mouseClickCount > 1); if(doubleClick) { selectAllText(); } else { //undo any block function mBlockStart = 0; mBlockEnd = 0; } //find out where the cursor should be S32 pos = calculateCursorPos( event.mousePoint ); // if the position is to the left if ( pos == -1 ) mCursorPos = 0; else if ( pos == -2 ) //else if the position is to the right mCursorPos = mTextBuffer.length(); else //else set the mCursorPos mCursorPos = pos; //save the mouseDragPos mMouseDragStart = mCursorPos; // lock the mouse mouseLock(); //set the drag var mDragHit = true; //let the parent get the event setFirstResponder(); }