[apps/exam_pop_up_controller] ContentView accesses the app directly

This commit is contained in:
Ruben Dashyan
2019-07-18 17:00:05 +02:00
committed by EmilieNumworks
parent b4cac92af2
commit 14835d0454
2 changed files with 6 additions and 10 deletions

View File

@@ -30,16 +30,16 @@ void ExamPopUpController::viewDidDisappear() {
}
void ExamPopUpController::didBecomeFirstResponder() {
m_contentView.setSelectedButton(0, app());
m_contentView.setSelectedButton(0);
}
bool ExamPopUpController::handleEvent(Ion::Events::Event event) {
if (event == Ion::Events::Left && m_contentView.selectedButton() == 1) {
m_contentView.setSelectedButton(0, app());
m_contentView.setSelectedButton(0);
return true;
}
if (event == Ion::Events::Right && m_contentView.selectedButton() == 0) {
m_contentView.setSelectedButton(1, app());
m_contentView.setSelectedButton(1);
return true;
}
return false;
@@ -78,14 +78,10 @@ void ExamPopUpController::ContentView::drawRect(KDContext * ctx, KDRect rect) co
ctx->fillRect(bounds(), KDColorBlack);
}
void ExamPopUpController::ContentView::setSelectedButton(int selectedButton, App * app) {
void ExamPopUpController::ContentView::setSelectedButton(int selectedButton) {
m_cancelButton.setHighlighted(selectedButton == 0);
m_okButton.setHighlighted(selectedButton == 1);
if (selectedButton == 0) {
app->setFirstResponder(&m_cancelButton);
} else {
app->setFirstResponder(&m_okButton);
}
app()->setFirstResponder(selectedButton == 0 ? &m_cancelButton : &m_okButton);
}
int ExamPopUpController::ContentView::selectedButton() {

View File

@@ -26,7 +26,7 @@ private:
public:
ContentView(Responder * parentResponder);
void drawRect(KDContext * ctx, KDRect rect) const override;
void setSelectedButton(int selectedButton, App * app);
void setSelectedButton(int selectedButton);
int selectedButton();
void setMessages(bool activingExamMode);
private: