* fPreviousText can be NULL for views that don't have focus (ie. by using SetEventMask()).

* Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15059 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2005-11-21 16:42:20 +00:00
parent 82d8744887
commit 2c5ab65d23
+4 -3
View File
@@ -68,7 +68,7 @@ _BTextInput_::Instantiate(BMessage *archive)
{ {
if (validate_instantiation(archive, "_BTextInput_")) if (validate_instantiation(archive, "_BTextInput_"))
return new _BTextInput_(archive); return new _BTextInput_(archive);
else
return NULL; return NULL;
} }
@@ -98,7 +98,7 @@ _BTextInput_::KeyDown(const char* bytes, int32 numBytes)
if (!TextControl()->IsEnabled()) if (!TextControl()->IsEnabled())
break; break;
if(strcmp(Text(), fPreviousText) != 0) { if (fPreviousText == NULL || strcmp(Text(), fPreviousText) != 0) {
TextControl()->Invoke(); TextControl()->Invoke();
free(fPreviousText); free(fPreviousText);
fPreviousText = strdup(Text()); fPreviousText = strdup(Text());
@@ -211,11 +211,12 @@ _BTextInput_::InsertText(const char *inText, int32 inLength,
if (buffer) { if (buffer) {
strcpy(buffer, inText); strcpy(buffer, inText);
for (int32 i = 0; i < inLength; i++) for (int32 i = 0; i < inLength; i++) {
if (buffer[i] == '\r' || buffer[i] == '\n') if (buffer[i] == '\r' || buffer[i] == '\n')
buffer[i] = ' '; buffer[i] = ' ';
} }
} }
}
BTextView::InsertText(buffer ? buffer : inText, inLength, inOffset, BTextView::InsertText(buffer ? buffer : inText, inLength, inOffset,
inRuns); inRuns);