(SendTextView) Check for important keys in each received byte

This commit is contained in:
Jaidyn Ann 2021-08-22 11:36:35 -05:00
parent c24c3187ad
commit bcb92de53c

View File

@ -1,4 +1,3 @@
#include <iostream>
/* /*
* Copyright 2021, Jaidyn Levesque <jadedctrl@teknik.io> * Copyright 2021, Jaidyn Levesque <jadedctrl@teknik.io>
* All rights reserved. Distributed under the terms of the MIT license. * All rights reserved. Distributed under the terms of the MIT license.
@ -38,22 +37,27 @@ SendTextView::KeyDown(const char* bytes, int32 numBytes)
fCurrentIndex = 0; fCurrentIndex = 0;
fCurrentWord.SetTo(""); fCurrentWord.SetTo("");
if ((bytes[0] == B_UP_ARROW) && (modifiers == 0)) { for (int i = 0; i < numBytes; i++) {
if ((bytes[i] == B_UP_ARROW) && (modifiers == 0)) {
_UpHistory(); _UpHistory();
return; return;
} }
else if ((bytes[0] == B_DOWN_ARROW) && (modifiers == 0)) { else if ((bytes[i] == B_DOWN_ARROW) && (modifiers == 0)) {
_DownHistory(); _DownHistory();
return; return;
} }
if ((bytes[0] == B_ENTER) && (modifiers & B_COMMAND_KEY)) if ((bytes[i] == B_ENTER)
&& ((modifiers & B_COMMAND_KEY) || (modifiers & B_SHIFT_KEY))) {
Insert("\n"); Insert("\n");
else if ((bytes[0] == B_ENTER) && (modifiers == 0)) { return;
}
else if (bytes[i] == B_ENTER) {
_AppendHistory(); _AppendHistory();
fChatView->MessageReceived(new BMessage(APP_CHAT)); fChatView->MessageReceived(new BMessage(APP_CHAT));
return;
}
} }
else
BTextView::KeyDown(bytes, numBytes); BTextView::KeyDown(bytes, numBytes);
} }