add keyHandler

pull/23/head
JuanJakobo 2021-06-04 21:28:50 +02:00
parent 94e6cff063
commit 4bb4af1412
2 changed files with 34 additions and 20 deletions

View File

@ -282,31 +282,35 @@ int EventHandler::pointerHandler(const int type, const int par1, const int par2)
PartialUpdate(_menu.getContentRect()->x, _menu.getContentRect()->y, _menu.getContentRect()->w, _menu.getContentRect()->h); PartialUpdate(_menu.getContentRect()->x, _menu.getContentRect()->y, _menu.getContentRect()->w, _menu.getContentRect()->h);
return 1; int EventHandler::keyHandler(const int type, const int par1, const int par2)
} {
//if loginView is shown if (type == EVT_KEYPRESS)
else if (_loginView != nullptr) {
//menu button
if (par1 == 23)
{ {
if (_loginView->logginClicked(par1, par2) == 2) _listView->firstPage();
}
else if (_listView != nullptr)
{
//left button
if (par1 == 24)
{ {
_menu.drawLoadingScreen(); _listView->prevPage();
}
if (_nextcloud.login(_loginView->getURL(), _loginView->getUsername(), _loginView->getPassword())) //right button
{ else if (par1 == 25)
_listView = std::unique_ptr<ListView>(new ListView(_menu.getContentRect(), _nextcloud.getItems())); {
_loginView.reset(); _listView->nextPage();
FullUpdate();
}
else
{
_menu.clearLoadingScreen();
Log::writeLog("login failed.");
}
return 1;
} }
} }
else
{
return 0;
}
return 1;
} }
return 0; return 0;
} }

View File

@ -85,6 +85,16 @@ private:
*/ */
int pointerHandler(const int type, const int par1, const int par2); int pointerHandler(const int type, const int par1, const int par2);
/**
* Handles key Events
*
* @param type event type
* @param par1 first argument of the event (is the key)
* @param par2 second argument of the event
* @return int returns if the event was handled
*/
int keyHandler(const int type, const int par1, const int par2);
/** /**
* Handles the cancel button on the progressbar * Handles the cancel button on the progressbar
* *