Add user closing fonticon autocomplete with escape
This commit is contained in:
parent
cfefd7d220
commit
c4d8638674
@ -232,6 +232,7 @@ namespace Components
|
||||
if(fontIconStart < 0 || fontIconStart == edit->cursor || !isalpha(static_cast<unsigned char>(edit->buffer[fontIconStart])))
|
||||
{
|
||||
context.autocompleteActive = false;
|
||||
context.userClosed = false;
|
||||
context.lastHash = 0;
|
||||
context.resultCount = 0;
|
||||
return;
|
||||
@ -245,6 +246,10 @@ namespace Components
|
||||
else if(context.selectedOffset >= context.resultOffset + FontIconAutocompleteContext::MAX_RESULTS)
|
||||
context.resultOffset = context.selectedOffset - (FontIconAutocompleteContext::MAX_RESULTS - 1);
|
||||
|
||||
// If the user closed the context do not draw or update
|
||||
if (context.userClosed)
|
||||
return;
|
||||
|
||||
context.autocompleteActive = true;
|
||||
|
||||
// No need to update results when in modifiers
|
||||
@ -453,6 +458,15 @@ namespace Components
|
||||
AutocompleteFill(context, scrPlace, edit);
|
||||
return true;
|
||||
|
||||
case Game::K_ESCAPE:
|
||||
if (!context.userClosed)
|
||||
{
|
||||
context.autocompleteActive = false;
|
||||
context.userClosed = true;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
@ -79,6 +79,7 @@ namespace Components
|
||||
|
||||
bool autocompleteActive;
|
||||
bool inModifiers;
|
||||
bool userClosed;
|
||||
unsigned int lastHash;
|
||||
std::string lastQuery;
|
||||
FontIconAutocompleteResult results[MAX_RESULTS];
|
||||
|
Loading…
Reference in New Issue
Block a user