Always apply the changes to a property in the text editor when changing focus.
Fixes #2749. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34847 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,9 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2006, Haiku.
|
* Copyright 2006-2009, Stephan Aßmus <[email protected]>.
|
||||||
* Distributed under the terms of the MIT License.
|
* All rights reserved. Distributed under the terms of the MIT License.
|
||||||
*
|
|
||||||
* Authors:
|
|
||||||
* Stephan Aßmus <[email protected]>
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "InputTextView.h"
|
#include "InputTextView.h"
|
||||||
@@ -69,10 +66,6 @@ InputTextView::KeyDown(const char* bytes, int32 numBytes)
|
|||||||
// revert any typing changes
|
// revert any typing changes
|
||||||
RevertChanges();
|
RevertChanges();
|
||||||
break;
|
break;
|
||||||
case B_TAB:
|
|
||||||
// skip BTextView implementation
|
|
||||||
BView::KeyDown(bytes, numBytes);
|
|
||||||
// fall through
|
|
||||||
case B_RETURN:
|
case B_RETURN:
|
||||||
ApplyChanges();
|
ApplyChanges();
|
||||||
break;
|
break;
|
||||||
@@ -89,12 +82,21 @@ InputTextView::KeyDown(const char* bytes, int32 numBytes)
|
|||||||
void
|
void
|
||||||
InputTextView::MakeFocus(bool focus)
|
InputTextView::MakeFocus(bool focus)
|
||||||
{
|
{
|
||||||
if (focus != IsFocus()) {
|
if (focus == IsFocus())
|
||||||
if (BView* view = Parent())
|
return;
|
||||||
view->Invalidate();
|
|
||||||
BTextView::MakeFocus(focus);
|
if (BView* view = Parent())
|
||||||
if (focus)
|
view->Invalidate();
|
||||||
SelectAll();
|
BTextView::MakeFocus(focus);
|
||||||
|
if (focus) {
|
||||||
|
SelectAll();
|
||||||
|
fTextBeforeFocus = Text();
|
||||||
|
} else {
|
||||||
|
// Only pressing ESC is supposed to revert to the previous
|
||||||
|
// value and not invoke, but in that case, the text will already
|
||||||
|
// be the previous value when we lose focus here.
|
||||||
|
if (fTextBeforeFocus != Text())
|
||||||
|
Invoke();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,15 +1,12 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2006, Haiku.
|
* Copyright 2006-2009, Stephan Aßmus <[email protected]>.
|
||||||
* Distributed under the terms of the MIT License.
|
* All rights reserved. Distributed under the terms of the MIT License.
|
||||||
*
|
|
||||||
* Authors:
|
|
||||||
* Stephan Aßmus <[email protected]>
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef INPUT_TEXT_VIEW_H
|
#ifndef INPUT_TEXT_VIEW_H
|
||||||
#define INPUT_TEXT_VIEW_H
|
#define INPUT_TEXT_VIEW_H
|
||||||
|
|
||||||
#include <Invoker.h>
|
#include <Invoker.h>
|
||||||
|
#include <String.h>
|
||||||
#include <TextView.h>
|
#include <TextView.h>
|
||||||
|
|
||||||
class InputTextView : public BTextView,
|
class InputTextView : public BTextView,
|
||||||
@@ -50,6 +47,8 @@ protected:
|
|||||||
void _CheckTextRect();
|
void _CheckTextRect();
|
||||||
|
|
||||||
bool fWasFocus;
|
bool fWasFocus;
|
||||||
|
BString fTextBeforeFocus;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // INPUT_TEXT_VIEW_H
|
#endif // INPUT_TEXT_VIEW_H
|
||||||
|
|||||||
Reference in New Issue
Block a user