Reputation: 626
I'd like to change horizontal scrolling behavior in JavaFX TableView
.
First, as context, I added the following key events:
This behavior was easily implemented, playing with indexes and using TableView.scrollToColumn()
and TableView.scrollTo()
.
The behavior I want to modify only occurs when a TableView
has more columns then the number of columns that can be displayed. I would like to change scroll behavior when current cell is in the far right displayed column. Actually, hitting TAB will scroll to next column, but this new current column will become first displayed column on the left.
Instead, I'd prefer that hitting TAB when current cell is in the far right column displays next column as the last displayed column (far right) instead of first displayed column on the left.
This is exactly actual behavior when SHIFT-TAB is pressed. Going left displays newly selected column as the first displayed column. I'd like to replicate this behavior when going right in a TableView
.
Any clues how to do it?
Regards.
Upvotes: 0
Views: 258
Reputation: 159566
This answer isn't a full answer to your problem but you only requested clues for a solution, which is what this is and it is easier to put this as an answer rather than as a series of comments.
Possible solutions:
Perhaps you might need a combination of some of the above to get what you want.
1. Modify the table view behavior input map
This is the solution suggested by kleopatra in comments:
try to tweak the mappings in the inputMap installed by the table's behavior
For a bit more info on the behavior implementation, see the answer to:
It includes a link to the current behavior source and information on how you might go about tweaking it for your application.
The implementation of this approach is a little tricky because it is part of the internal com.sun
API for JavaFX, which perhaps should not be directly used, as your application may break without warning in future JavaFX versions if you use it.
2. Remap the key events routed to the table.
Perhaps the technique of filtering input events in this answer:
might help you get the solution you want. However, again, I'm not sure.
You would need to do more work than that solution.
In addition to filtering the tab key, you would need to fire off a new artificial event to create shift+tab event.
And you would need to ensure that the filtering is done at the appropriate level (the capturing of the event for focus handling for tab might be at the scene level rather than the table view itself).
Upvotes: 1