From 213d80002c524439ef9931c5efd39fc375a08d39 Mon Sep 17 00:00:00 2001 From: Romain Goyet Date: Wed, 8 Apr 2020 21:31:32 -0400 Subject: [PATCH] [escher/layout_field] Insertion event can be customized --- escher/include/escher/layout_field.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/escher/include/escher/layout_field.h b/escher/include/escher/layout_field.h index 2db62c47b..7642d8b2a 100644 --- a/escher/include/escher/layout_field.h +++ b/escher/include/escher/layout_field.h @@ -19,6 +19,7 @@ public: ScrollableView(parentResponder, &m_contentView, this), EditableField(inputEventHandlerDelegate), m_contentView(), + m_insertionCursorEvent(Ion::Events::None), m_delegate(delegate) {} void setDelegates(InputEventHandlerDelegate * inputEventHandlerDelegate, LayoutFieldDelegate * delegate) { m_inputEventHandlerDelegate = inputEventHandlerDelegate; m_delegate = delegate; } @@ -33,6 +34,7 @@ public: Poincare::Layout layout() const { return m_contentView.expressionView()->layout(); } CodePoint XNTCodePoint(CodePoint defaultXNTCodePoint) override; void putCursorRightOfLayout(); + void setInsertionCursorEvent(Ion::Events::Event event) { m_insertionCursorEvent = event; } // ScrollableView void setBackgroundColor(KDColor c) override { @@ -60,7 +62,7 @@ private: void scrollRightOfLayout(Poincare::Layout layoutR); void scrollToBaselinedRect(KDRect rect, KDCoordinate baseline); void insertLayoutAtCursor(Poincare::Layout layoutR, Poincare::Expression correspondingExpression, bool forceCursorRightOfLayout = false); - bool eventShouldUpdateInsertionCursor(Ion::Events::Event event) { return event == Ion::Events::Up; } + bool eventShouldUpdateInsertionCursor(Ion::Events::Event event) { return event == m_insertionCursorEvent; } class ContentView : public View { public: @@ -109,6 +111,7 @@ private: bool m_isEditing; }; ContentView m_contentView; + Ion::Events::Event m_insertionCursorEvent; LayoutFieldDelegate * m_delegate; };