wiki:TEXT_STABLE_SELECTION_R0

Version 15 (modified by diana, 16 years ago) (diff)

--

Error: Macro BackLinksMenu(None) failed
compressed data is corrupt

Error: Macro TicketQuery(summary=TEXT_STABLE_SELECTION_R0, format=table, col=summary|owner|status|type|component|priority|effort|importance, rows=description|analysis_owners|analysis_reviewers|analysis_score|design_owners|design_reviewers|design_score|implementation_owners|implementation_reviewers|implementation_score|test_owners|test_reviewers|test_score|) failed
current transaction is aborted, commands ignored until end of transaction block

Analysis

Overview

Text select -

  • Text selection is done by
    • clicking and dragging on text
    • double clicking on a word (selects the whole word) (word - symbols not containing tab, space, page break or other special(hidden) characters)
    • navigate (arrows) select text in desired position. For example, on up/down the text is selected to the same position on the previous/next line if there is text on it or to the end of the line otherwise. In all other cases the selection is from the previous position to the current carriage position (depends on cursor movement bahavior)
  • Should highlight text (with inversed colors)
  • Should apply style to selection only. If nothing is selected and carriage is in a word, applies the style to the whole word. Otherwise, should apply styles from cursor position to the next non-existing character.
  • Text selection should be draggable
  • Cursor position is local for non-chained frames. Selection should be kept for each different frame (cursor position - too)
  • Selection is dropped when the carriage is moved (mouse, arrows without shift)
  • Text select in Preview mode, Presentation mode and Reader app
    • Cursor position is kept, but the carriage is not shown. This allows selecting text by shift+arrow, the behavior is the same as in the author app
    • Note that arrows without shift should only scroll and not change the carriage (cursor position)

Task requirements

  • Add select support for text frames
  • Clicking on a position with mouse sets the carriage to this position. Position is saved.
  • Double clicking on a word selects the whole word
  • shift + left (right) arrow select text in desired position (one character).
  • Should highlight text (with inversed colors)
  • Should apply style to selection only. If nothing is selected, should apply styles from cursor position to the following non-existing character.

Task result

The result should be code

Implementation idea

Selection is local for a frame, so add two new properties in the text frame class - one for the select caret and one for selection list (which hot units are selected). Also add interaction logic for handling selection operations

(Add links to related tasks that could be useful or helpful.)

How to demo

  • Start Sophie2.0
  • Add text frame
  • Write some text - sophie2.0 text selection example
  • Select the first word
  • Select the third word while first word is selected

Design

Notes: The scope of the task is reduced to selection only with the keyboard. The task requirements 2, 3 and 4 are not implemented. Text selection is something that is related to the text frame, so two new properties will be added in org.sophie2.base.scene.interfaces.HotTextSceneElement :

  • markPos : HotPos - will represent the selection position in the text. When there's no selection markPos is the same as the caretPos

For selected text will be considered everything that is between caretPos and markPos. The HotUnits there should be added to selectedUnits.

For presentation of the selected text to the user will be used reverse background/color model (color XORmodel). For now this feature is part of HotTextLayout related classes and more specially Atom.

HotTextPlaceLogic is an enumeration that handles text interaction which is related to some positioning - events that have parameter Place. In it there are literals for - navigating through text and deleting text (both using Place as an argument for their events), so it's a good place to add a new enumeration literal - SELECT_OPERATION. It will be handler for selection activities (shift + left/right arrow etc.). In the same enumeration support for markPos must be added to already existing literals :

  • When navigating through text markPos and caretPos should advance in same way
  • When deleting text markPos and caretPos should be positioned in the same place

An initial test can be found here:branches/private/diana/sophie2-platform/modules/org.sophie2.author/src/test/java/org/sophie2/author/TextSelectionTest.java[3311]

Implementation

Done according to the design. [3314]

Testing

(Place the testing results here.)

Comments

(Write comments for this or later revisions here.)