Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

toAutoSpanColumns + navigation #649

Closed
ghost opened this issue Sep 1, 2016 · 7 comments
Closed

toAutoSpanColumns + navigation #649

ghost opened this issue Sep 1, 2016 · 7 comments
Assignees
Labels
Grid Mode Open for Discussion There are several possibilites to address the issue and anyone is invited for comments.

Comments

@ghost
Copy link

ghost commented Sep 1, 2016

We are in the process of upgrading from 1.31 => 4.8.7 (last version with BCB6 support - done but patched) => 6.3.
In 1.31 navigation like VK_LEFT honors toAutoSpanColumns ie if you are positioned right of a spanned cell and fires VK_LEFT => you will move to the first-spanned-cell. In 6.3 you end up in the last-spanned-cell and the cell-focus-rectangle disappears.

Dunno why this was dropped somewhere between 1.31 and 4.8.7...

@joachimmarder
Copy link
Contributor

joachimmarder commented Sep 1, 2016

Dunno why this was dropped somewhere between 1.31 and 4.8.7...

Sorry, no. I took over the project with V5. And I personally never used spanned cells.

If you think this is a bug, could you please attach a sample project that allows to replicate the issue? Also a modified demo project would be fine.

@ghost
Copy link
Author

ghost commented Sep 1, 2016

Hmmm, I patch:ed 4.8.7 internally using code from 1.31 - I'll try to do the same for 6.3 and post a patch here (I guess you are allowed to use 1.31 code yes?)...

@joachimmarder
Copy link
Contributor

(I guess you are allowed to use 1.31 code yes?)...

I think so, I guess it was published under the same license as the current version.

@ghost
Copy link
Author

ghost commented Sep 5, 2016

VK_{UP|DOWN|LEFT|RIGHT} should use the following 1.31 functions:

function TBaseVirtualTree.GetMergedColumn(Node: PVirtualNode; Column: TColumnIndex; ConsiderAllowFocus: bool): TColumnIndex;
// if auto column spanning is enabled and Column is merged look for the first non merged column, otherwise Column is returned
begin
  Result := Column;
  if (toAutoSpanColumns in FOptions.FAutoOptions) and Header.UseColumns then
    while (Result > NoColumn) and ColumnIsEmpty(Node, Result) do
      Result := FHeader.FColumns.GetPreviousVisibleColumn(Result, ConsiderAllowFocus);
end;

and

function TBaseVirtualTree.GetNextNonMergedColumn(Node: PVirtualNode; Column: TColumnIndex; ConsiderAllowFocus: bool): TColumnIndex;
// look for next visible non-merged column. if auto column spanning isn't enabled the function is equal GetNextVisibleColumn
begin
  Result := FHeader.FColumns.GetNextVisibleColumn(Column, ConsiderAllowFocus);
  if (toAutoSpanColumns in FOptions.FAutoOptions) and Header.UseColumns then
    while (Result >= 0) and (Result < Header.Columns.Count) and ColumnIsEmpty(Node, Result) do
      Result := FHeader.FColumns.GetNextVisibleColumn(Result, ConsiderAllowFocus);
end;

VK_LEFT and VK_RIGHT is simple; use the functions above to set FocusedColumn.

VK_UP and VK_DOWN is tricky; 1.31 mimics the navigation of excel (wider indicates span):

[ ][ ][5][ ][ ]
[4      ][ ][ ]
[ ][ ][3][ ][ ]
[ ][2   ][ ][ ]
[ ][ ][1][ ][ ]

Start position is 1 - VK_UP four time moves us to position 2-5. That is we need to keep track of the actual column. This was handled by FFocusedKeyColumn in 1.31:

FFocusedKeyColumn: Integer; // cache for FFocusedColumn when moving focus with the keyboard, used to get
                            // a correct behavior when using voAutoSpanColumns (i.e columns can be merged).

VK_LEFT and VK_RIGHT should use the functions above to set FocusedColumn (using FFocusedKeyColumn as parameter).

VK_LEFT/VK_RIGHT/MouseDown events updates FFocusedColumn => we must update FFocusedKeyColumn. The problem is all other places that updates FFocusedColumn; I'm not familiar enough with the code to determine where FFocusedKeyColumn updates should be placed...

@joachimmarder joachimmarder added Grid Mode Open for Discussion There are several possibilites to address the issue and anyone is invited for comments. labels Sep 6, 2016
@joachimmarder
Copy link
Contributor

Would you mind attaching a sample project that makes it easy to test this behavior?

@joachimmarder
Copy link
Contributor

Is there any news on this issue? If no sample project is supplied, I will close this issue sooner or later.

sanjayssk pushed a commit that referenced this issue Apr 18, 2017
… left and right keys

* Introduced 2 new local functions in WMKeyDown to handle skipping of autospanned empty column with left and right cell navigation
@sanjayssk
Copy link
Contributor

Fixed. But found the same problem with VK_TAB forward and backward. However, that uses a completely different code by using a function pointer. Hence, making another issue for it and closing this issue.

ValtsS pushed a commit to ValtsS/Virtual-TreeView that referenced this issue Jan 25, 2019
…nColumns for left and right keys

* Introduced 2 new local functions in WMKeyDown to handle skipping of autospanned empty column with left and right cell navigation

# Conflicts:
#	CHANGES.txt
#	Source/VirtualTrees.pas
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Grid Mode Open for Discussion There are several possibilites to address the issue and anyone is invited for comments.
Projects
None yet
Development

No branches or pull requests

2 participants