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

Listvew mouse event doesn't cause a selecteditemchange event to fire #3317

Closed
dasien opened this issue Mar 13, 2024 Discussed in #3316 · 0 comments · Fixed by #3321
Closed

Listvew mouse event doesn't cause a selecteditemchange event to fire #3317

dasien opened this issue Mar 13, 2024 Discussed in #3316 · 0 comments · Fixed by #3321
Labels
bug v1 For Issues & PRs targetting v1.x

Comments

@dasien
Copy link
Contributor

dasien commented Mar 13, 2024

Discussed in #3316

Originally posted by dasien March 13, 2024
Kind of a beginner here, so this could very likely be something i am doing wrong. I have a listview on which i am tracking the MouseClick, KeyUp, and SelectedItemChanged events. When the listview is first loaded, i set the selected item to the first item in the list. Also, the listview has AllowsMarking and MultiSelect set to true.

The first mouse click in the listview fires the MouseClick event 3 times and it fires the SelectedItemChanged event. Subsequent mouse clicks still fire the MouseClick event (3 times), but do not fire the SelectedItemChanged event. Inside the MouseClick, i am checking the listview.SelectedItem, and i do see that number changing from click to click, to the last row on which i clicked, but the SelectedItemChanged event isn't firing.

The issue for me is that i am using that Change event to track the current row in the listview, so that future operations can act on one, or a collection, of items associated with the selected rows.

Similar actions using the keyboard (moving between rows for example) seem to fire both the KeyUp event and SelectedItemChanged events every time.

Is there something i am doing incorrectly or out of order to not get that SelectedItemChanged event to fire? Alternatively, is there some way to compute the row which was clicked in the listview? I could then capture the item associated with the row which was clicked and store it in my list of selected items. Somehow the underlying system knows which row has been clicked, because it is tracking the change to the SelectedItem and marking the correct row with a check mark and highlighting that as the selected row.

Any ideas would be appreciated, and happy to share some code if needed. It is pretty straightforward for this part, just registering events and putting a breakpoint to check what is firing and when.

Thank you!

BDisp added a commit to BDisp/Terminal.Gui that referenced this issue Mar 13, 2024
@tig tig added bug v1 For Issues & PRs targetting v1.x labels Mar 14, 2024
@tig tig closed this as completed in #3321 Mar 16, 2024
tig added a commit that referenced this issue Mar 16, 2024
…arks-click.fix_3317

Fixes #3317. v1-Listvew mouse event doesn't cause a SelectedItemChanged event to fire
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug v1 For Issues & PRs targetting v1.x
Projects
None yet
2 participants