Skip to content

Commit

Permalink
W_EDITBOX: Improve ESC handling behavior
Browse files Browse the repository at this point in the history
This enables hitting ESC to:
1.) Clear the current text in the EditBox (if it has text)
2.) End editing mode (if the EditBox is empty)

Thus, to quickly cancel out / close an in-game chat box that contains text, hit escape twice (once to clear, once to end editing mode).

NOTE: There are unrelated issues with how the main menus handle widget & input processing (and the ESC key) that prevent this from working in the main menus (yet). But the in-game edit boxes, such as the in-game chatbox, can take advantage of this immediately.
  • Loading branch information
past-due committed Apr 3, 2019
1 parent 093aad3 commit 809dd2a
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions lib/widget/editbox.cpp
Expand Up @@ -417,6 +417,21 @@ void W_EDITBOX::run(W_CONTEXT *psContext)
break;
case INPBUF_ESC :
debug(LOG_INPUT, "EditBox cursor escape");
if (aText.length() > 0)
{
// hitting ESC while the editbox contains text clears the text
aText.clear();
insPos = 0;
printStart = 0;
fitStringStart();
}
else
{
// hitting ESC while the editbox is empty ends editing mode
StopTextInput();
screenPointer->setFocus(nullptr);
return;
}
break;

default:
Expand Down

0 comments on commit 809dd2a

Please sign in to comment.