diff --git a/apps/code/python_toolbox.cpp b/apps/code/python_toolbox.cpp index 6b5686b18..f08bdcacd 100644 --- a/apps/code/python_toolbox.cpp +++ b/apps/code/python_toolbox.cpp @@ -696,14 +696,13 @@ KDCoordinate PythonToolbox::rowHeight(int j) { return Toolbox::rowHeight(j); } -bool PythonToolbox::selectLeaf(int selectedRow) { +bool PythonToolbox::selectLeaf(int selectedRow, bool quitToolbox) { ToolboxMessageTree * node = (ToolboxMessageTree *)m_messageTreeModel->childAtIndex(selectedRow); #if defined(INCLUDE_ULAB) if(node->text() == I18n::Message::UlabDocumentationLink){ return true; } #endif - m_selectableTableView.deselectTable(); if(node->insertedText() == I18n::Message::IonSelector){ m_ionKeys.setSender(sender()); Container::activeApp()->displayModalViewController(static_cast(&m_ionKeys), 0.f, 0.f, Metric::PopUpTopMargin, Metric::PopUpLeftMargin, 0, Metric::PopUpRightMargin); @@ -719,7 +718,10 @@ bool PythonToolbox::selectLeaf(int selectedRow) { editedText = strippedEditedText; } sender()->handleEventWithText(editedText, true); - Container::activeApp()->dismissModalViewController(); + if (quitToolbox) { + m_selectableTableView.deselectTable(); + Container::activeApp()->dismissModalViewController(); + } return true; } diff --git a/apps/code/python_toolbox.h b/apps/code/python_toolbox.h index 7c66af03f..9be9f4aa9 100644 --- a/apps/code/python_toolbox.h +++ b/apps/code/python_toolbox.h @@ -20,10 +20,11 @@ public: const ToolboxMessageTree * rootModel() const override; protected: KDCoordinate rowHeight(int j) override; - bool selectLeaf(int selectedRow) override; + bool selectLeaf(int selectedRow, bool quitToolbox) override; MessageTableCellWithMessage * leafCellAtIndex(int index) override; MessageTableCellWithChevron* nodeCellAtIndex(int index) override; int maxNumberOfDisplayedRows() override; + bool canStayInMenu() override { return true; } constexpr static int k_maxNumberOfDisplayedRows = 13; // = 240/(13+2*3) // 13 = minimal string height size // 3 = vertical margins diff --git a/apps/code/variable_box_controller.cpp b/apps/code/variable_box_controller.cpp index 279c9c57c..5f3e73bcc 100644 --- a/apps/code/variable_box_controller.cpp +++ b/apps/code/variable_box_controller.cpp @@ -365,7 +365,7 @@ int VariableBoxController::typeAndOriginAtLocation(int i, NodeOrigin * resultOri } -bool VariableBoxController::selectLeaf(int rowIndex) { +bool VariableBoxController::selectLeaf(int rowIndex, bool quitToolbox) { assert(rowIndex >= 0 && rowIndex < numberOfRows()); m_selectableTableView.deselectTable(); diff --git a/apps/code/variable_box_controller.h b/apps/code/variable_box_controller.h index 81504ac0a..f20b64091 100644 --- a/apps/code/variable_box_controller.h +++ b/apps/code/variable_box_controller.h @@ -80,7 +80,7 @@ private: // NestedMenuController HighlightCell * leafCellAtIndex(int index) override { assert(false); return nullptr; } HighlightCell * nodeCellAtIndex(int index) override { assert(false); return nullptr; } - bool selectLeaf(int rowIndex) override; + bool selectLeaf(int rowIndex, bool quitToolbox) override; void insertTextInCaller(const char * text, int textLength = -1); // Loading diff --git a/apps/math_toolbox.cpp b/apps/math_toolbox.cpp index e2146ecc6..da06d0bb6 100644 --- a/apps/math_toolbox.cpp +++ b/apps/math_toolbox.cpp @@ -877,7 +877,7 @@ MathToolbox::MathToolbox() : { } -bool MathToolbox::selectLeaf(int selectedRow) { +bool MathToolbox::selectLeaf(int selectedRow, bool quitToolbox) { ToolboxMessageTree * messageTree = (ToolboxMessageTree *)m_messageTreeModel->childAtIndex(selectedRow); m_selectableTableView.deselectTable(); diff --git a/apps/math_toolbox.h b/apps/math_toolbox.h index 2ade3318f..b883bf182 100644 --- a/apps/math_toolbox.h +++ b/apps/math_toolbox.h @@ -9,7 +9,7 @@ public: MathToolbox(); const ToolboxMessageTree * rootModel() const override; protected: - bool selectLeaf(int selectedRow) override; + bool selectLeaf(int selectedRow, bool quitToolbox) override; MessageTableCellWithMessage * leafCellAtIndex(int index) override; MessageTableCellWithChevron* nodeCellAtIndex(int index) override; int maxNumberOfDisplayedRows() override; diff --git a/apps/math_variable_box_controller.cpp b/apps/math_variable_box_controller.cpp index f8e01ea9f..87b671788 100644 --- a/apps/math_variable_box_controller.cpp +++ b/apps/math_variable_box_controller.cpp @@ -193,7 +193,7 @@ bool MathVariableBoxController::returnToPreviousMenu() { return AlternateEmptyNestedMenuController::returnToPreviousMenu(); } -bool MathVariableBoxController::selectLeaf(int selectedRow) { +bool MathVariableBoxController::selectLeaf(int selectedRow, bool quitToolbox) { if (isDisplayingEmptyController()) { /* We do not want to handle OK/EXE events in that case. */ return false; diff --git a/apps/math_variable_box_controller.h b/apps/math_variable_box_controller.h index 86f968303..6fe80f576 100644 --- a/apps/math_variable_box_controller.h +++ b/apps/math_variable_box_controller.h @@ -42,7 +42,7 @@ private: void setPage(Page page); bool selectSubMenu(int selectedRow) override; bool returnToPreviousMenu() override; - bool selectLeaf(int selectedRow) override; + bool selectLeaf(int selectedRow, bool quitToolbox) override; I18n::Message nodeLabelAtIndex(int index); Poincare::Layout expressionLayoutForRecord(Ion::Storage::Record record, int index); const char * extension() const; diff --git a/escher/include/escher/nested_menu_controller.h b/escher/include/escher/nested_menu_controller.h index ca671a1b7..41333398f 100644 --- a/escher/include/escher/nested_menu_controller.h +++ b/escher/include/escher/nested_menu_controller.h @@ -65,7 +65,8 @@ protected: bool handleEventForRow(Ion::Events::Event event, int selectedRow); virtual bool selectSubMenu(int selectedRow); virtual bool returnToPreviousMenu(); - virtual bool selectLeaf(int selectedRow) = 0; + virtual bool selectLeaf(int selectedRow, bool quitToolbox) = 0; + virtual bool canStayInMenu() { return false; }; virtual int stackRowOffset() const { return 0; } InputEventHandler * sender() { return m_sender; } virtual HighlightCell * leafCellAtIndex(int index) = 0; diff --git a/escher/src/nested_menu_controller.cpp b/escher/src/nested_menu_controller.cpp index 735f5a32c..3911ffcc3 100644 --- a/escher/src/nested_menu_controller.cpp +++ b/escher/src/nested_menu_controller.cpp @@ -156,8 +156,11 @@ bool NestedMenuController::handleEventForRow(Ion::Events::Event event, int rowIn if ((event == Ion::Events::OK || event == Ion::Events::EXE || event == Ion::Events::Right) && typeAtLocation(0, selectedRow()) == NodeCellType) { return selectSubMenu(rowIndex); } + if (canStayInMenu() && ((event == Ion::Events::ShiftOK || event == Ion::Events::ShiftEXE) && typeAtLocation(0, selectedRow()) == LeafCellType)) { + return selectLeaf(rowIndex, false); + } if ((event == Ion::Events::OK || event == Ion::Events::EXE) && typeAtLocation(0, selectedRow()) == LeafCellType) { - return selectLeaf(rowIndex); + return selectLeaf(rowIndex, true); } return false; } diff --git a/ion/include/ion/events.h b/ion/include/ion/events.h index 1764eb595..4dccae5be 100644 --- a/ion/include/ion/events.h +++ b/ion/include/ion/events.h @@ -141,6 +141,7 @@ constexpr Event ShiftLeft = Event::ShiftKey(Keyboard::Key::Left); constexpr Event ShiftRight = Event::ShiftKey(Keyboard::Key::Right); constexpr Event ShiftUp = Event::ShiftKey(Keyboard::Key::Up); constexpr Event ShiftDown = Event::ShiftKey(Keyboard::Key::Down); +constexpr Event ShiftOK = Event::ShiftKey(Keyboard::Key::OK); constexpr Event AlphaLock = Event::ShiftKey(Keyboard::Key::Alpha); constexpr Event Cut = Event::ShiftKey(Keyboard::Key::XNT); @@ -183,6 +184,8 @@ constexpr Event ShiftSeven = Event::ShiftKey(Keyboard::Key::Seven); constexpr Event ShiftEight = Event::ShiftKey(Keyboard::Key::Eight); constexpr Event ShiftNine = Event::ShiftKey(Keyboard::Key::Nine); +constexpr Event ShiftEXE = Event::ShiftKey(Keyboard::Key::EXE); + // Alpha constexpr Event AlphaLeft = Event::AlphaKey(Keyboard::Key::Left); diff --git a/ion/src/shared/keyboard/layout_B2/layout_events.cpp b/ion/src/shared/keyboard/layout_B2/layout_events.cpp index 339092597..cc659c321 100644 --- a/ion/src/shared/keyboard/layout_B2/layout_events.cpp +++ b/ion/src/shared/keyboard/layout_B2/layout_events.cpp @@ -16,7 +16,7 @@ const EventData s_dataForEvent[4 * Event::PageSize] = { T("1"), T("2"), T("3"), T("+"), T("-"), U(), T("0"), T("."), T("ᴇ"), TL(), TL(), U(), // Shift - TL(), TL(), TL(), TL(), U(), U(), + TL(), TL(), TL(), TL(), TL(), U(), TL(), U(), U(), U(), U(), U(), U(), U(), TL(), TL(), TL(), TL(), T("["), T("]"), T("{"), T("}"), T("_"), T("→"), @@ -24,7 +24,7 @@ const EventData s_dataForEvent[4 * Event::PageSize] = { T("μ"), TL(), T("Ω"), T("(\x11)"), U(), U(), TL(), TL(), TL(), TL(), TL(), U(), TL(), TL(), TL(), TL(), TL(), U(), - TL(), TL(), TL(), TL(), U(), U(), + TL(), TL(), TL(), TL(), TL(), U(), // Alpha TL(), TL(), TL(), TL(), U(), U(), U(), U(), U(), U(), U(), U(), @@ -61,7 +61,7 @@ const char * const s_nameForEvent[255] = { "One", "Two", "Three", "Plus", "Minus", nullptr, "Zero", "Dot", "EE", "Ans", "EXE", nullptr, //Shift, - "ShiftLeft", "ShiftUp", "ShiftDown", "ShiftRight", nullptr, nullptr, + "ShiftLeft", "ShiftUp", "ShiftDown", "ShiftRight", "ShiftOK", nullptr, "ShiftHome", nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, "AlphaLock", "Cut", "Copy", "Paste", "Clear", "LeftBracket", "RightBracket", "LeftBrace", "RightBrace", "Underscore", "Sto", @@ -69,7 +69,7 @@ const char * const s_nameForEvent[255] = { "Micro", nullptr, "Omega", nullptr, "DoubleParenthesis", nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, "BrightnessPlus", "BrightnessMinus", nullptr, - nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, + nullptr, nullptr, nullptr, nullptr, "ShiftEXE", nullptr, //Alpha, "AlphaLeft", "AlphaUp", "AlphaDown", "AlphaRight", nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, diff --git a/ion/src/shared/keyboard/layout_B3/layout_events.cpp b/ion/src/shared/keyboard/layout_B3/layout_events.cpp index 2cd94ce53..6ccf51c3b 100644 --- a/ion/src/shared/keyboard/layout_B3/layout_events.cpp +++ b/ion/src/shared/keyboard/layout_B3/layout_events.cpp @@ -16,7 +16,7 @@ const EventData s_dataForEvent[4 * Event::PageSize] = { T("1"), T("2"), T("3"), T("+"), T("-"), U(), T("0"), T("."), T("ᴇ"), TL(), TL(), U(), // Shift - TL(), TL(), TL(), TL(), U(), U(), + TL(), TL(), TL(), TL(), TL(), U(), TL(), U(), U(), U(), U(), U(), U(), U(), TL(), TL(), TL(), TL(), T("["), T("]"), T("{"), T("}"), T("_"), T("→"), @@ -24,7 +24,7 @@ const EventData s_dataForEvent[4 * Event::PageSize] = { T("μ"), TL(), T("Ω"), T("(\x11)"), U(), U(), TL(), TL(), TL(), TL(), TL(), U(), TL(), TL(), TL(), TL(), TL(), U(), - TL(), TL(), TL(), TL(), U(), U(), + TL(), TL(), TL(), TL(), TL(), U(), // Alpha TL(), TL(), TL(), TL(), U(), U(), U(), U(), U(), U(), U(), U(), @@ -61,7 +61,7 @@ const char * const s_nameForEvent[255] = { "One", "Two", "Three", "Plus", "Minus", nullptr, "Zero", "Dot", "EE", "Ans", "EXE", nullptr, //Shift, - "ShiftLeft", "ShiftUp", "ShiftDown", "ShiftRight", nullptr, nullptr, + "ShiftLeft", "ShiftUp", "ShiftDown", "ShiftRight", "ShiftOK", nullptr, "ShiftHome", nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, "AlphaLock", "Cut", "Copy", "Paste", "Clear", "LeftBracket", "RightBracket", "LeftBrace", "RightBrace", "Underscore", "Sto", @@ -69,7 +69,7 @@ const char * const s_nameForEvent[255] = { "Micro", nullptr, "Omega", nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, "BrightnessPlus", "BrightnessMinus", nullptr, - nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, + nullptr, nullptr, nullptr, nullptr, "ShiftEXE", nullptr, //Alpha, "AlphaLeft", "AlphaUp", "AlphaDown", "AlphaRight", nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr,