Skip to content

Commit

Permalink
Fixed issue #649: Cell navigation problems with toAutoSpanColumns for…
Browse files Browse the repository at this point in the history
… left and right keys

* Introduced 2 new local functions in WMKeyDown to handle skipping of autospanned empty column with left and right cell navigation
  • Loading branch information
Sanjay Kanade authored and Sanjay Kanade committed Apr 18, 2017
1 parent dd5e96d commit b4329b4
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* Fixed issue #714: Integer overflow in TBaseVirtualTree's InternalAddFromStream
* Fixed issue #500: Issue with node selection "from code" for disabled nodes with toLevelSelectConstraint option
* Fixed issue #499: Incorrect behavior with toLevelSelectConstraint and ctrl+A
* Fixed issue #649: Cell navigation problems with toAutoSpanColumns for left and right keys

V6.6 (04 Apr 2017)
* Fixed issue #705: Added support for RAD Studio 10.2 Tokyo
Expand Down
77 changes: 73 additions & 4 deletions Source/VirtualTrees.pas
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,15 @@
// Anthony Mills, Alexander Egorushkin (BCB), Mathias Torell (BCB), Frank van den Bergh, Vadim Sedulin, Peter Evans,
// Milan Vandrovec (BCB), Steve Moss, Joe White, David Clark, Anders Thomsen, Igor Afanasyev, Eugene Programmer,
// Corbin Dunn, Richard Pringle, Uli Gerhardt, Azza, Igor Savkic, Daniel Bauten, Timo Tegtmeier, Dmitry Zegebart,
// Andreas Hausladen, Joachim Marder, Roman Kassebaum, Vincent Parret, Dietmar R�sler
// Andreas Hausladen, Joachim Marder, Roman Kassebaum, Vincent Parret, Dietmar R�sler, Sanjay Kanade,
// and everyone that sent pull requests: https://github.com/Virtual-TreeView/Virtual-TreeView/pulls?q=
// Beta testers:
// Freddy Ertl, Hans-J�rgen Schnorrenberg, Werner Lehmann, Jim Kueneman, Vadim Sedulin, Moritz Franckenstein,
// Wim van der Vegt, Franc v/d Westelaken
// Indirect contribution (via publicly accessible work of those persons):
// Alex Denissov, Hiroyuki Hori (MMXAsm expert)
// Documentation:
// Markus Spoettl and toolsfactory GbR (http://www.doc-o-matic.com/, sponsoring Soft Gems development
// Markus Spoettl and toolsfactory GbR (http://www.doc-o-matic.com/, sponsoring Virtual TreeView development
// with a free copy of the Doc-O-Matic help authoring system), Sven H. (Step by step tutorial)
// Source repository:
// https://github.com/Virtual-TreeView/Virtual-TreeView
Expand Down Expand Up @@ -16790,6 +16791,70 @@ procedure TBaseVirtualTree.WMKeyDown(var Message: TWMKeyDown);
KeyState: TKeyboardState;
Buffer: array[0..1] of AnsiChar;

//--------------- local functions -------------------------------------------
function getPreviousVisibleAutoSpanColumn(acolumn: TColumnIndex; anode: PVirtualNode): TColumnIndex;
var
PrevColumn: Integer;
begin
if (not assigned(anode))
or (not FHeader.UseColumns)
or (not (toAutoSpanColumns in FOptions.FAutoOptions))
or (acolumn = FHeader.MainColumn) then
begin
//previously existing logic
result := FHeader.Columns.GetPreviousVisibleColumn(acolumn, True);
exit;
end;
//consider auto spanning
with FHeader.FColumns do //standard loop for auto span
begin
PrevColumn := acolumn;
repeat
result := FHeader.Columns.GetPreviousVisibleColumn(PrevColumn);
if (result = InvalidColumn) or
(not ColumnIsEmpty(anode, result))
//Any other BidiMode is not supported as already
//documented by original developer
or (Items[result].BidiMode <> bdLeftToRight) then
Break;
PrevColumn := result;
until False;
end;
end;

//---------------------------------------------------------------------------
function getNextVisibleAutoSpanColumn(acolumn: TColumnIndex; anode: PVirtualNode): TColumnIndex;
var
NextColumn: Integer;
begin
if (not assigned(anode))
or (not FHeader.UseColumns)
or (not (toAutoSpanColumns in FOptions.FAutoOptions))
or (acolumn = FHeader.MainColumn) then
begin
//previously existing logic
result := FHeader.Columns.GetNextVisibleColumn(acolumn, True);
exit;
end;
//consider auto spanning
with FHeader.FColumns do //standard loop for auto span
begin
NextColumn := acolumn;
repeat
result := FHeader.Columns.GetNextVisibleColumn(NextColumn);
if (result = InvalidColumn) or
not ColumnIsEmpty(anode, result)
//Any other BidiMode is not supported as already
//documented by original developer
or (Items[result].BidiMode <> bdLeftToRight) then
Break;
NextColumn := result;
until False;
end;
end;

//--------------- end local functions ---------------------------------------

begin
// Make form key preview work and let application modify the key if it wants this.
inherited;
Expand Down Expand Up @@ -17059,7 +17124,7 @@ procedure TBaseVirtualTree.WMKeyDown(var Message: TWMKeyDown);
Context := NoColumn;
if (toExtendedFocus in FOptions.FSelectionOptions) and (toGridExtensions in FOptions.FMiscOptions) then
begin
Context := FHeader.Columns.GetPreviousVisibleColumn(FFocusedColumn, True);
Context := getPreviousVisibleAutoSpanColumn(FFocusedColumn, FFocusedNode);
if Context > NoColumn then
FocusedColumn := Context;
end
Expand Down Expand Up @@ -17109,7 +17174,7 @@ procedure TBaseVirtualTree.WMKeyDown(var Message: TWMKeyDown);
Context := NoColumn;
if (toExtendedFocus in FOptions.FSelectionOptions) and (toGridExtensions in FOptions.FMiscOptions) then
begin
Context := FHeader.Columns.GetNextVisibleColumn(FFocusedColumn, True);
Context := getNextVisibleAutoSpanColumn(FFocusedColumn, FFocusedNode);
if Context > NoColumn then
FocusedColumn := Context;
end
Expand Down Expand Up @@ -22592,6 +22657,8 @@ procedure TBaseVirtualTree.HandleMouseDown(var Message: TWMMouse; var HitInfo: T
FullRowDrag: Boolean; // Start dragging anywhere within a node's bound.
NodeRect: TRect;

//--------------- local functions -------------------------------------------

//Fix for issue: 310 whenever there is a need to invalidate a column, consider
//auto spanned columns if applicable
procedure invalidateWithAutoSpan(acolumn: TColumnIndex; anode: PVirtualNode);
Expand Down Expand Up @@ -22623,6 +22690,8 @@ procedure TBaseVirtualTree.HandleMouseDown(var Message: TWMMouse; var HitInfo: T
end;
end;

//--------------- end local functions ---------------------------------------

begin
if [tsWheelPanning, tsWheelScrolling] * FStates <> [] then
begin
Expand Down

0 comments on commit b4329b4

Please sign in to comment.