View Issue Details

IDProjectCategoryView StatusLast Update
0023756LazarusLCLpublic2013-02-03 00:56
ReporterMartin Friebe Assigned ToJesus Reyes  
Status assignedResolutionopen 
Product Version1.1 (SVN) 
Summary0023756: StringGrid: Right/Left keys not send to Editor (if editing, and selected all)
DescriptionStringGrid with

Enter some content into an existing cell, Move to other cell, move back to cell, F2 to activate editor (as text will be selected: right left key should edit text (remove selection), but they go to next cell.

There is no way to keep existing text, and add to it, when starting editing with F2.

Same, if pasting a word (strg-v) into a cell. It will be all selected, and writing behind the pasted word is not possible

Can also be triggered by just selecting all
Additional InformationSeems to relate to the left/right keys will go to next cell, if the caret is at end/start of editor.

But with select all, it prevents using the editor.

After long search, I found that home/end can be used to unselect. But imho few users will find that.
TagsNo tags attached.
Fixed in Revision
Attached Files


Bart Broersma

2013-01-26 22:43

developer   ~0065203

Last edited: 2013-01-26 22:51

Hmm. Pressing F2 again also enables using cursor keys.
Moving to next/previous cell when cursor is at end/begin of text is rather natural, if you compare it with editing tables in a wordprocessor or even cells in a spreadsheet.
When text is selected however (by pressing F2), this sucks.
However if you disable selecting next/previous cell when all text is selected, using the left/right cursor keys to navigate the cells becomes a PITA...

Bart Broersma

2013-01-26 22:49

developer   ~0065204

Here's a thing I don't understand.
Pressing F2 calls (in TCustomgrid.Keydown) EditorShow(False).
The False indicating that the editor should not select the text in the control.

Martin Friebe

2013-01-26 23:15

manager   ~0065205

Even with all selected, the caret should be at the left or right end of the text/selection.

So at least one of the cursor keys should unselect, and stay in cell.
Neither does....

Libre Calc makes a difference between a cell that:
- went into auto edit by typing text. > cursor movement can change cell (even if all is selected)
- went into edit by F2. > Must be left with enter key (or tab). Cursor left/right/up/down will not leave cell
- text was pasted > does not activate editor, so pasted text is overwritten if text is typed (but F2 will still work)

Though we do not need to implement all of this.


If all text is selected then pressing cursor left/right will unselected the text. The next cursor in that direction then changes cell (as no text is selected)

It already behaves like this, if only some text (last 3 out of 5 chars) are selected.
So that would only be consequent to use this for all selected too.

Note: using shift cursor left/right is not affected by this change.

Jesus Reyes

2013-01-27 08:51

developer   ~0065207

This is on purpose and is what we (well, I) call FastEditing, if I understood ok, what you describe can be achieved by setting Grid.FastEditing := false.

FastEditing=true by default because it helps to quickly entering data in stringgrid.

When FastEditing=true, as Bart as found, pressing F2 again starts normal text cursor navigation on the editor, the double pressing F2 feature was added because it was assumed that when fast editing is on moving between cells is more frequent than moving between editing chars.

Martin Friebe

2013-01-27 11:39

manager   ~0065213

Last edited: 2013-01-27 11:53

What is on purpose? That a selection behaves different, dependent on if it selects all or part of the text?

Even if I press F2 twice (column 2 of 3, so there is a left and a right neighbour):
- press F2 twice, select *LAST* 3 out of 5 chars (select either from middle of cell to end of cell, or end of cell to middle of cell) => use cursor left or right => this will deselect the text, but stay in the cell

- Do the same but select *FIRST* 3 of 5 (or all) => use cursor left or right => this will move to other cell

Note: In both cases the position of the caret does not Matter:
- Selecting last 3 from middle to end => Caret will be at end of cell.
-- If there IS NO selection, and the caret is at end of cell then it goes to next cell when I press cursor right.
-- If there IS A selection, and the caret is at end of cell then it does NOT go
to next cell when I press cursor right.

And if all is selected, it does not matter on which side of the selection/cell the caret is...

This behaviour is definitely not consistent.

This applies for:
- twice F2, and re-apply selection
- start edit by typing, and then do selection
- once F2 and mouse click
- AND it applies with the option eoAlwaysShowEditor
- AND it happens if the property AutoEdit is on or off

except with eoAlwaysShowEditor and a selection of the first 3 of 5 chars, cursor right stays in the cell, while cursor left goes to neighbour cell. (without eoAlwaysShowEditor both cursor keys change cell)

I did not find an option called fast editing

EDIT: found the option, it is not published

Bart Broersma

2013-01-27 13:50

developer   ~0065215

With FastEditing it works as expected?

Any objections to make the property FastEditing published (in TDrawGrid and TStringGrid)?

Martin Friebe

2013-01-27 15:40

manager   ~0065218

I haven't tested FastEditing for all combinations, but at first sight, it works as advertised..

Still leaves 1 or 2 issues:

** 1)

The above (without FastEdit) is inconsistent. part selection at star, behaves different, than part selection at end. Why?

There are many ways to solve this:
It needs to be decided, how important the caret pos in those cases is.
It seems if all is selected, then cursor keys should always go to other cell.

Note: in a edit (in grid) with the text abcFOOdef, if FOO is selected, and the caret before "F" (selected backward) then cursor right goes F|OO

So if all was selected with cursor at star of text, then which rule should be followed for cursor right?

- If it is Next Cell, then
  - all selected, cursor left/right change cell
  - if part selected on begin of cell, only cursor left changes cell (happens currently in some but not all config)
  - if part selected at end of cell, only cursor right changes cell

** 2)
feature request:
When cursor right/left occurs while a selection exists never go to next cell, but deselect.
If there is no selection, then go to next cell.

Make FastEdit dependent on how the editor was entered.
- Editor was entered by start typing > FastEdit ON
- Editor was entered by F2 > FastEdit OFF

So before puplishing it, maybe make it a enum type, instead of boolean:
feAlways, feNever, feOnlyF2

Jesus Reyes

2013-01-27 23:00

developer   ~0065234

Yes, there seems to be a bug or two over there, fast editing supposed to give a way to escape from text editor if caret is at some text boundary, standard text selection in this mode is/should be less important but yet possible.

This means that under fast editing mode, if you select text, you are expected to replace selection with some text, further text selection/edition cause some delay and is where an additional F2 is acceptable, and if further selection is needed then SHIFT should be pressed.

I think the bug here is that sometimes next cell is selected even when SHIFT is pressed, if SHIFT is pressed, no matter where the caret is, selection should not move to another cell and this is what you describe as inconsistency (I guess).

If there is a partial selection and the caret is at the text boundary the next cell will be selected ONLY if pressed key moves caret AWAY from the text, if it moves the caret into the text, standard text selection should occur.

So this is how FastEditing=true should work, the idea of making this an enum is not bad, we could even make it to work like in libre calc or excel or what is needed, we could add for example a published property EditingMode with values like emDefault (or emFastEdit), emSpreadsheet (libre calc or excel), emDelphi (for those looking for "used to" behaviour) etc.

Martin Friebe

2013-01-27 23:54

manager   ~0065237

I did not (yet) test the behaviour for shift left/right.

The main issue is without shift.

Issue History

Date Modified Username Field Change
2013-01-26 16:33 Martin Friebe New Issue
2013-01-26 16:33 Martin Friebe LazTarget => -
2013-01-26 22:43 Bart Broersma Note Added: 0065203
2013-01-26 22:44 Bart Broersma Status new => confirmed
2013-01-26 22:49 Bart Broersma Note Added: 0065204
2013-01-26 22:51 Bart Broersma Note Edited: 0065203
2013-01-26 23:15 Martin Friebe Note Added: 0065205
2013-01-27 08:51 Jesus Reyes Note Added: 0065207
2013-01-27 11:39 Martin Friebe Note Added: 0065213
2013-01-27 11:43 Martin Friebe Note Edited: 0065213
2013-01-27 11:53 Martin Friebe Note Edited: 0065213
2013-01-27 13:50 Bart Broersma Note Added: 0065215
2013-01-27 15:40 Martin Friebe Note Added: 0065218
2013-01-27 23:00 Jesus Reyes Note Added: 0065234
2013-01-27 23:54 Martin Friebe Note Added: 0065237
2013-02-03 00:56 Jesus Reyes Assigned To => Jesus Reyes
2013-02-03 00:56 Jesus Reyes Status confirmed => assigned