(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,23 +37,28 @@ 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++) {
_UpHistory(); if ((bytes[i] == B_UP_ARROW) && (modifiers == 0)) {
return; _UpHistory();
} return;
else if ((bytes[0] == B_DOWN_ARROW) && (modifiers == 0)) { }
_DownHistory(); else if ((bytes[i] == B_DOWN_ARROW) && (modifiers == 0)) {
return; _DownHistory();
} return;
}
if ((bytes[0] == B_ENTER) && (modifiers & B_COMMAND_KEY)) if ((bytes[i] == B_ENTER)
Insert("\n"); && ((modifiers & B_COMMAND_KEY) || (modifiers & B_SHIFT_KEY))) {
else if ((bytes[0] == B_ENTER) && (modifiers == 0)) { Insert("\n");
_AppendHistory(); return;
fChatView->MessageReceived(new BMessage(APP_CHAT)); }
else if (bytes[i] == B_ENTER) {
_AppendHistory();
fChatView->MessageReceived(new BMessage(APP_CHAT));
return;
}
} }
else BTextView::KeyDown(bytes, numBytes);
BTextView::KeyDown(bytes, numBytes);
} }