wiki:TEXT_STABLE_SELECTION_R0
Last modified 16 years ago Last modified on 07/06/09 22:11:31

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 selection is done by:
    • clicking and dragging on text with the mouse (selects the dragged over text);
    • double-clicking on a word (selects the whole word);
    • navigating with the keyboard (Shift+arrows, Ctrl+Shift+arrows) selects the text in the desired position. The selection is from the previous position to the current carriage position (depends on cursor movement bahavior).
  • It should highlight text (with inversed colors).
  • It should apply style to selection only. If nothing is selected and carriage is in a word, it applies the style to the whole word. Otherwise, it should apply styles from the cursor position to the next non-existing character.
  • 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 (by the mouse or by using the arrows without shift).
  • Text select in Preview mode, Presentation mode and Reader app should be the following:
    • 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
    • Using 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 the mouse should set the carriage to this position. Position should be saved.
  • Shift + left/right arrow should select the text in desired position (one character).
  • Ctrl + Shift left/right arrow should select the text in desired position (one word).
  • Selected text should be highlighted (with inversed colors).

Note: Selection with the mouse or by double-clicking a word will not be supported at this iteration.

Task result

Source code

Implementation idea

Selection is local for a frame, so add a new propertiy in the text frame class, holding the selection caret position. Also add interaction logic for handling selection operations.

None

How to demo

  • Start Sophie2.0
  • Add a text frame, write some text and demonstrate the selection.

Design

Text selection is something that is related to the text frame, so a new property 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. 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 [3461]

The classes related to the test are in changeset: [3314] [3891]

Implementation

Merged to the trunk in [4069].

Testing

(Place the testing results here.)

Comments

(Write comments for this or later revisions here.)