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

When OnAddToSelection is called, GetFirstSelected returns nil #487

Closed
vincentparrett opened this issue Jan 21, 2015 · 1 comment
Closed
Assignees
Labels
Milestone

Comments

@vincentparrett
Copy link
Contributor

From [email protected] on October 10, 2014 00:54:17

Hello,

I am using r712 on Windows 7 SP1 and I have noticed a strange behavior when moving between nodes using the keyboard.
I have plugged the OnAddToSelection event and I am using the GetFirstSelected/GetNextSelected construct to get the nodes that are selected.
However, when the newly selected node (parameter to OnAddToSelection) does not come up in the GetFirstSelected iteration.

If I use the mouse and the OnFocusChanged event, I do get the appropriate enumeration with GetFirstSelected.

So right now, I can have a valid selection with the mouse, but I'm stuck when using the keyboard.

I have attached a small sample application that shows the behavior, please let me know if I missed something obvious.

Attachment: keyboard selection.zip

Original issue: http://code.google.com/p/virtual-treeview/issues/detail?id=487

@vincentparrett
Copy link
Contributor Author

From [email protected] on October 09, 2014 11:28:59

The reason for this behavior is that FSelectionCount is updated at the end of InternalAddToSelection(), and the OnAddToSelection event is fired before, for every node in the passed array.

Idea: We could store the original FSelectionCount in a local variable OldSelectionCount and increment FSelectionCount each time we fire the OnAddToSelection event. At the end we can set FSelectionCount := OldSelectionCount + NewLength;

Owner: [email protected]
Labels: -Priority-Medium Priority-Low

@joachimmarder joachimmarder self-assigned this Jan 26, 2015
@joachimmarder joachimmarder added this to the Version 6.1 milestone Mar 25, 2015
ValtsS pushed a commit to ValtsS/Virtual-TreeView that referenced this issue Jan 25, 2019
…stSelected returns nil

# Conflicts:
#	Source/VirtualTrees.pas
joachimmarder added a commit that referenced this issue Apr 5, 2022
…aged within the OnAddToSelect event hanlder. Solves #948
joachimmarder added a commit that referenced this issue Apr 5, 2022
Removed assertion done for #487 that may fire if the selection is changed within the OnAddToSelect event handler. Solves #948
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants