[apps/code] ConsoleController: when becoming first responder, check if a

controller is displayed and switch the first responder accordingly
This commit is contained in:
Émilie Feral
2020-03-24 17:13:22 +01:00
parent 7e73afc654
commit 89b54d424e

View File

@@ -190,7 +190,16 @@ void ConsoleController::viewWillAppear() {
}
void ConsoleController::didBecomeFirstResponder() {
Container::activeApp()->setFirstResponder(&m_editCell);
if (viewControllerIsDisplayed(nullptr)) {
Container::activeApp()->setFirstResponder(&m_editCell);
} else {
/* A view controller might be displayed: for example, when pushing the
* console on the stack controller, we auto-import scripts during the
* 'viewWillAppear' and then we set the console as first responder. The
* sandbox or the matplotlib controller might have been pushed in the
* auto-import. */
Container::activeApp()->setFirstResponder(m_displayedViewController);
}
}
bool ConsoleController::handleEvent(Ion::Events::Event event) {