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])))
|
if(fontIconStart < 0 || fontIconStart == edit->cursor || !isalpha(static_cast<unsigned char>(edit->buffer[fontIconStart])))
|
||||||
{
|
{
|
||||||
context.autocompleteActive = false;
|
context.autocompleteActive = false;
|
||||||
|
context.userClosed = false;
|
||||||
context.lastHash = 0;
|
context.lastHash = 0;
|
||||||
context.resultCount = 0;
|
context.resultCount = 0;
|
||||||
return;
|
return;
|
||||||
@ -245,6 +246,10 @@ namespace Components
|
|||||||
else if(context.selectedOffset >= context.resultOffset + FontIconAutocompleteContext::MAX_RESULTS)
|
else if(context.selectedOffset >= context.resultOffset + FontIconAutocompleteContext::MAX_RESULTS)
|
||||||
context.resultOffset = context.selectedOffset - (FontIconAutocompleteContext::MAX_RESULTS - 1);
|
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;
|
context.autocompleteActive = true;
|
||||||
|
|
||||||
// No need to update results when in modifiers
|
// No need to update results when in modifiers
|
||||||
@ -453,6 +458,15 @@ namespace Components
|
|||||||
AutocompleteFill(context, scrPlace, edit);
|
AutocompleteFill(context, scrPlace, edit);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
case Game::K_ESCAPE:
|
||||||
|
if (!context.userClosed)
|
||||||
|
{
|
||||||
|
context.autocompleteActive = false;
|
||||||
|
context.userClosed = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -79,6 +79,7 @@ namespace Components
|
|||||||
|
|
||||||
bool autocompleteActive;
|
bool autocompleteActive;
|
||||||
bool inModifiers;
|
bool inModifiers;
|
||||||
|
bool userClosed;
|
||||||
unsigned int lastHash;
|
unsigned int lastHash;
|
||||||
std::string lastQuery;
|
std::string lastQuery;
|
||||||
FontIconAutocompleteResult results[MAX_RESULTS];
|
FontIconAutocompleteResult results[MAX_RESULTS];
|
||||||
|
Loading…
Reference in New Issue
Block a user