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) 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) if (!repeat)
doClose = true; doClose = true;

View File

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

View File

@ -16,6 +16,8 @@ namespace ui
constexpr int MAX_WIDTH = 64; constexpr int MAX_WIDTH = 64;
class FontEditor: public ui::Window class FontEditor: public ui::Window
{ {
void HandleExit();
private: private:
ByteString dataFile; ByteString dataFile;
std::map<String::value_type, unsigned char> fontWidths; 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) switch (key)
{ {
case SDLK_AC_BACK:
if (ALLOW_QUIT)
{
ui::Engine::Ref().ConfirmExit();
}
break;
case SDLK_TAB: //Tab case SDLK_TAB: //Tab
c->ChangeBrush(); c->ChangeBrush();
break; break;

View File

@ -366,7 +366,7 @@ void Window::DoKeyPress(int key, int scan, bool repeat, bool shift, bool ctrl, b
if (!stop) if (!stop)
OnKeyPress(key, scan, repeat, shift, ctrl, alt); OnKeyPress(key, scan, repeat, shift, ctrl, alt);
if (key == SDLK_ESCAPE) if (key == SDLK_ESCAPE || key == SDLK_AC_BACK)
OnTryExit(Escape); OnTryExit(Escape);
if (key == SDLK_KP_ENTER || key == SDLK_RETURN) 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) if (repeat)
return; return;
if (key == SDLK_ESCAPE) if (key == SDLK_ESCAPE || key == SDLK_AC_BACK)
c->Exit(); c->Exit();
else if (key == SDLK_LCTRL || key == SDLK_RCTRL) else if (key == SDLK_LCTRL || key == SDLK_RCTRL)
c->SetMoveToFront(false); c->SetMoveToFront(false);

View File

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