Handle back button on android

This commit is contained in:
Tamás Bálint Misius 2023-10-16 23:37:59 +02:00
parent 73be29aa61
commit 9f50249ca8
No known key found for this signature in database
GPG Key ID: 5B472A12F6ECA9F2
7 changed files with 13 additions and 4 deletions

View File

@ -25,7 +25,7 @@ ConsoleView::ConsoleView():
void ConsoleView::DoKeyPress(int key, int scan, bool repeat, bool shift, bool ctrl, bool alt)
{
if ((ui::Engine::Ref().GraveExitsConsole && scan == SDL_SCANCODE_GRAVE && key != '~') || key == SDLK_ESCAPE)
if ((ui::Engine::Ref().GraveExitsConsole && scan == SDL_SCANCODE_GRAVE && key != '~') || key == SDLK_ESCAPE || key == SDLK_AC_BACK)
{
if (!repeat)
doClose = true;

View File

@ -254,6 +254,7 @@ void ElementSearchActivity::OnKeyPress(int key, int scan, bool repeat, bool shif
if(firstResult)
gameController->SetActiveTool(0, firstResult);
case SDLK_ESCAPE:
case SDLK_AC_BACK:
exit = true;
break;
case SDLK_LSHIFT:

View File

@ -16,6 +16,8 @@ namespace ui
constexpr int MAX_WIDTH = 64;
class FontEditor: public ui::Window
{
void HandleExit();
private:
ByteString dataFile;
std::map<String::value_type, unsigned char> fontWidths;

View File

@ -1597,6 +1597,12 @@ void GameView::OnKeyPress(int key, int scan, bool repeat, bool shift, bool ctrl,
{
switch (key)
{
case SDLK_AC_BACK:
if (ALLOW_QUIT)
{
ui::Engine::Ref().ConfirmExit();
}
break;
case SDLK_TAB: //Tab
c->ChangeBrush();
break;

View File

@ -366,7 +366,7 @@ void Window::DoKeyPress(int key, int scan, bool repeat, bool shift, bool ctrl, b
if (!stop)
OnKeyPress(key, scan, repeat, shift, ctrl, alt);
if (key == SDLK_ESCAPE)
if (key == SDLK_ESCAPE || key == SDLK_AC_BACK)
OnTryExit(Escape);
if (key == SDLK_KP_ENTER || key == SDLK_RETURN)

View File

@ -201,7 +201,7 @@ void LocalBrowserView::OnKeyPress(int key, int scan, bool repeat, bool shift, bo
{
if (repeat)
return;
if (key == SDLK_ESCAPE)
if (key == SDLK_ESCAPE || key == SDLK_AC_BACK)
c->Exit();
else if (key == SDLK_LCTRL || key == SDLK_RCTRL)
c->SetMoveToFront(false);

View File

@ -643,7 +643,7 @@ void SearchView::OnKeyPress(int key, int scan, bool repeat, bool shift, bool ctr
{
if (repeat)
return;
if (key == SDLK_ESCAPE)
if (key == SDLK_ESCAPE || key == SDLK_AC_BACK)
c->Exit();
else if ((focusedComponent_ != pageTextbox && focusedComponent_ != searchField) && scan == SDL_SCANCODE_A && ctrl)
c->SelectAllSaves();