diff --git a/escher/include/escher/layout_field.h b/escher/include/escher/layout_field.h index 8532a6cd2..8008a47ec 100644 --- a/escher/include/escher/layout_field.h +++ b/escher/include/escher/layout_field.h @@ -44,7 +44,7 @@ public: } // Selection - void resetSelection() { m_contentView.resetSelection(); } + bool resetSelection() { return m_contentView.resetSelection(); } void deleteSelection(); private: diff --git a/escher/src/layout_field.cpp b/escher/src/layout_field.cpp index 2dee5b5a9..3fb7d428f 100644 --- a/escher/src/layout_field.cpp +++ b/escher/src/layout_field.cpp @@ -376,7 +376,21 @@ bool LayoutField::privateHandleEvent(Ion::Events::Event event) { return false; } +static inline bool IsSimpleMoveEvent(Ion::Events::Event event) { + return event == Ion::Events::Left + || event == Ion::Events::Right + || event == Ion::Events::Up + || event == Ion::Events::Down; +} + bool LayoutField::privateHandleMoveEvent(Ion::Events::Event event, bool * shouldRecomputeLayout) { + if (!IsSimpleMoveEvent(event)) { + return false; + } + if (resetSelection()) { + *shouldRecomputeLayout = true; + return true; + } LayoutCursor result; if (event == Ion::Events::Left) { result = m_contentView.cursor()->cursorAtDirection(LayoutCursor::MoveDirection::Left, shouldRecomputeLayout); @@ -384,7 +398,8 @@ bool LayoutField::privateHandleMoveEvent(Ion::Events::Event event, bool * should result = m_contentView.cursor()->cursorAtDirection(LayoutCursor::MoveDirection::Right, shouldRecomputeLayout); } else if (event == Ion::Events::Up) { result = m_contentView.cursor()->cursorAtDirection(LayoutCursor::MoveDirection::Up, shouldRecomputeLayout); - } else if (event == Ion::Events::Down) { + } else { + assert(event == Ion::Events::Down); result = m_contentView.cursor()->cursorAtDirection(LayoutCursor::MoveDirection::Down, shouldRecomputeLayout); } if (result.isDefined()) {