FIX: Bug [0000620] "Incorrect last file selection"

This commit is contained in:
Alexander Koblov 2013-01-04 19:22:10 +00:00
commit c489ad5df0
5 changed files with 37 additions and 26 deletions

View file

@ -205,6 +205,9 @@ begin
FBriefView.FRangeSelecting :=
(ssShift in Shift) and
(SavedKey in [VK_LEFT, VK_RIGHT, VK_HOME, VK_END, VK_PRIOR, VK_NEXT]);
// Special case for selection with shift key (works like VK_INSERT)
if (SavedKey in [VK_UP, VK_DOWN]) and (ssShift in Shift) then
FBriefView.InvertActiveFile;
case Key of
VK_LEFT:
@ -283,7 +286,7 @@ begin
inherited KeyDown(Key, Shift);
if ssShift in Shift then
if FBriefView.FRangeSelecting then
begin
FileIndex := CellToIndex(Col, Row);
if FileIndex <> InvalidFileIndex then

View file

@ -1685,6 +1685,9 @@ begin
ColumnsView.FRangeSelecting :=
(ssShift in Shift) and
(SavedKey in [VK_HOME, VK_END, VK_PRIOR, VK_NEXT]);
// Special case for selection with shift key (works like VK_INSERT)
if (SavedKey in [VK_UP, VK_DOWN]) and (ssShift in Shift) then
ColumnsView.InvertActiveFile;
{$IFDEF LCLGTK2}
// Workaround for GTK2 - up and down arrows moving through controls.
@ -1698,7 +1701,7 @@ begin
inherited KeyDown(Key, Shift);
if (ssShift in Shift) and (Row >= FixedRows) then
if (ColumnsView.FRangeSelecting) and (Row >= FixedRows) then
ColumnsView.Selection(SavedKey, Row - FixedRows);
end;

View file

@ -1429,6 +1429,9 @@ begin
ColumnsView.FRangeSelecting :=
(ssShift in Shift) and
(SavedKey in [VK_HOME, VK_END, VK_PRIOR, VK_NEXT]);
// Special case for selection with shift key (works like VK_INSERT)
if (SavedKey in [VK_UP, VK_DOWN]) and (ssShift in Shift) then
ColumnsView.InvertActiveFile;
// Override scrolling with PageUp, PageDown because VirtualTreeView scrolls too much.
case SavedKey of
@ -1496,7 +1499,7 @@ begin
inherited WMKeyDown(Message);
if (ssShift in Shift) and Assigned(FocusedNode) then
if (ColumnsView.FRangeSelecting) and Assigned(FocusedNode) then
ColumnsView.Selection(SavedKey, FocusedNode^.Index);
end;

View file

@ -60,6 +60,7 @@ type
FRangeSelectionEndIndex: Integer;
FRangeSelectionState: Boolean;
FUpdatingActiveFile: Boolean;
procedure InvertActiveFile;
procedure AfterChangePath; override;
procedure CreateDefault(AOwner: TWinControl); override;
procedure DoFileIndexChanged(NewFileIndex: PtrInt);
@ -228,31 +229,12 @@ end;
procedure TOrderedFileView.DoHandleKeyDown(var Key: Word; Shift: TShiftState);
var
mi: TMenuItem;
Index: PtrInt;
begin
// check if ShiftState is equal to quick search / filter modes
if quickSearch.CheckSearchOrFilter(Key) then
Exit;
case Key of
VK_UP, VK_DOWN:
begin
if ssShift in Shift then
begin
if IsActiveItemValid then
begin
Index:= GetActiveFileIndex;
if IsFileIndexInRange(Index) then
begin
InvertFileSelection(FFiles[Index], False);
if (Index = 0) or (Index = FFiles.Count - 1) then
RedrawFile(Index);
end;
UpdateRangeSelectionState;
end;
end
end;
VK_ESCAPE:
begin
if Filtered and (GetCurrentWorkType <> fvwtNone) then
@ -617,10 +599,10 @@ begin
// It just needs to correspond to scroll positions (similar to TScrollCode).
case Key of
VK_HOME, VK_END: ;
VK_PRIOR, VK_LEFT:
VK_PRIOR, VK_UP, VK_LEFT:
if CurIndex > 0 then
OneLess;
VK_NEXT, VK_RIGHT:
VK_NEXT, VK_DOWN, VK_RIGHT:
if CurIndex < FFiles.Count - 1 then
OneLess;
else
@ -768,5 +750,22 @@ begin
end;
end;
procedure TOrderedFileView.InvertActiveFile;
var
Index: PtrInt;
begin
if IsActiveItemValid then
begin
Index:= GetActiveFileIndex;
if IsFileIndexInRange(Index) then
begin
InvertFileSelection(FFiles[Index], False);
if (Index = 0) or (Index = FFiles.Count - 1) then
RedrawFile(Index);
end;
UpdateRangeSelectionState;
end;
end;
end.

View file

@ -174,7 +174,10 @@ begin
// Set RangeSelecting before cursor is moved.
FThumbView.FRangeSelecting :=
(ssShift in Shift) and
(SavedKey in [VK_LEFT, VK_RIGHT, VK_HOME, VK_END, VK_PRIOR, VK_NEXT]);
(SavedKey in [VK_UP, VK_DOWN, VK_HOME, VK_END, VK_PRIOR, VK_NEXT]);
// Special case for selection with shift key (works like VK_INSERT)
if (SavedKey in [VK_LEFT, VK_RIGHT]) and (ssShift in Shift) then
FThumbView.InvertActiveFile;
case Key of
VK_LEFT:
@ -223,7 +226,7 @@ begin
inherited KeyDown(Key, Shift);
if ssShift in Shift then
if FThumbView.FRangeSelecting then
begin
FileIndex := CellToIndex(Col, Row);
if FileIndex <> InvalidFileIndex then