Prevent editable widgets from adding various characters when F1-F12 is pressed by the user.

Formerly the code just casted the "ascii" value of the key event to "byte"
and thus truncating the character value. Now that would be fine, if we
would not allow values >= 256 in the ascii field, for example 322 for F8
which in turn resulted in a "B" added to the editable field. I just added
a check for the values being in the byte range before doing the cast,
which fixes this.

svn-id: r48967
This commit is contained in:
Johannes Schickel 2010-05-08 18:30:00 +00:00
parent 78a99ce6a6
commit ada03c57b3

View File

@ -208,7 +208,7 @@ bool EditableWidget::handleKeyDown(Common::KeyState state) {
}
void EditableWidget::defaultKeyDownHandler(Common::KeyState &state, bool &dirty, bool &forcecaret, bool &handled) {
if (tryInsertChar((byte)state.ascii, _caretPos)) {
if (state.ascii < 256 && tryInsertChar((byte)state.ascii, _caretPos)) {
_caretPos++;
dirty = true;
forcecaret = true;