From b2afb8800bb033a04bb3ecdf0363068d56648ef1 Mon Sep 17 00:00:00 2001 From: Jacek Antonelli Date: Fri, 15 Aug 2008 23:44:54 -0500 Subject: Second Life viewer sources 1.15.0.2 --- linden/indra/llui/lllineeditor.cpp | 35 +++++++++++++---------------------- 1 file changed, 13 insertions(+), 22 deletions(-) (limited to 'linden/indra/llui/lllineeditor.cpp') diff --git a/linden/indra/llui/lllineeditor.cpp b/linden/indra/llui/lllineeditor.cpp index 1ca17fe..ec156ba 100644 --- a/linden/indra/llui/lllineeditor.cpp +++ b/linden/indra/llui/lllineeditor.cpp @@ -4,6 +4,7 @@ * * Copyright (c) 2001-2007, Linden Research, Inc. * + * Second Life Viewer Source Code * The source code in this file ("Source Code") is provided by Linden Lab * to you under the terms of the GNU General Public License, version 2.0 * ("GPL"), unless you have obtained a separate licensing agreement @@ -115,7 +116,7 @@ LLLineEditor::LLLineEditor(const LLString& name, const LLRect& rect, S32 max_length_bytes, void (*commit_callback)(LLUICtrl* caller, void* user_data ), void (*keystroke_callback)(LLLineEditor* caller, void* user_data ), - void (*focus_lost_callback)(LLLineEditor* caller, void* user_data ), + void (*focus_lost_callback)(LLUICtrl* caller, void* user_data ), void* userdata, LLLinePrevalidateFunc prevalidate_func, LLViewBorder::EBevel border_bevel, @@ -132,7 +133,6 @@ LLLineEditor::LLLineEditor(const LLString& name, const LLRect& rect, mCommitOnFocusLost( TRUE ), mRevertOnEsc( TRUE ), mKeystrokeCallback( keystroke_callback ), - mFocusLostCallback( focus_lost_callback ), mIsSelecting( FALSE ), mSelectionStart( 0 ), mSelectionEnd( 0 ), @@ -166,6 +166,8 @@ LLLineEditor::LLLineEditor(const LLString& name, const LLRect& rect, mGLFont = LLFontGL::sSansSerifSmall; } + setFocusLostCallback(focus_lost_callback); + mMinHPixels = mBorderThickness + UI_LINEEDITOR_H_PAD + mBorderLeft; mMaxHPixels = mRect.getWidth() - mMinHPixels - mBorderThickness - mBorderRight; @@ -186,7 +188,6 @@ LLLineEditor::LLLineEditor(const LLString& name, const LLRect& rect, LLLineEditor::~LLLineEditor() { - mFocusLostCallback = NULL; mCommitOnFocusLost = FALSE; gFocusMgr.releaseFocusIfNeeded( this ); @@ -211,11 +212,8 @@ LLString LLLineEditor::getWidgetTag() const void LLLineEditor::onFocusLost() { - if( mFocusLostCallback ) - { - mFocusLostCallback( this, mCallbackUserData ); - } - + LLUICtrl::onFocusLost(); + if( mCommitOnFocusLost && mText.getString() != mPrevText) { onCommit(); @@ -502,7 +500,7 @@ BOOL LLLineEditor::handleMouseDown(S32 x, S32 y, MASK mask) startSelection(); } - gFocusMgr.setMouseCapture( this, &LLLineEditor::onMouseCaptureLost ); + gFocusMgr.setMouseCapture( this ); } // delay cursor flashing @@ -515,14 +513,14 @@ BOOL LLLineEditor::handleMouseDown(S32 x, S32 y, MASK mask) BOOL LLLineEditor::handleHover(S32 x, S32 y, MASK mask) { BOOL handled = FALSE; - if (gFocusMgr.getMouseCapture() != this && (x < mBorderLeft || x > (mRect.getWidth() - mBorderRight))) + if (!hasMouseCapture() && (x < mBorderLeft || x > (mRect.getWidth() - mBorderRight))) { return LLUICtrl::handleHover(x, y, mask); } if( getVisible() ) { - if( (gFocusMgr.getMouseCapture() == this) && mIsSelecting ) + if( (hasMouseCapture()) && mIsSelecting ) { if (x != mLastSelectionX || y != mLastSelectionY) { @@ -580,9 +578,9 @@ BOOL LLLineEditor::handleMouseUp(S32 x, S32 y, MASK mask) { BOOL handled = FALSE; - if( gFocusMgr.getMouseCapture() == this ) + if( hasMouseCapture() ) { - gFocusMgr.setMouseCapture( NULL, NULL ); + gFocusMgr.setMouseCapture( NULL ); handled = TRUE; } @@ -1916,11 +1914,9 @@ BOOL LLLineEditor::prevalidateASCII(const LLWString &str) return rv; } -//static -void LLLineEditor::onMouseCaptureLost( LLMouseHandler* old_captor ) +void LLLineEditor::onMouseCaptureLost() { - LLLineEditor* self = (LLLineEditor*) old_captor; - self->endSelection(); + endSelection(); } @@ -1935,11 +1931,6 @@ void LLLineEditor::setKeystrokeCallback(void (*keystroke_callback)(LLLineEditor* mKeystrokeCallback = keystroke_callback; } -void LLLineEditor::setFocusLostCallback(void (*keystroke_callback)(LLLineEditor* caller, void* user_data)) -{ - mFocusLostCallback = keystroke_callback; -} - // virtual LLXMLNodePtr LLLineEditor::getXML(bool save_children) const { -- cgit v1.1