fix key focus and selection

Resolves #72
This commit is contained in:
marhali 2022-01-05 18:31:37 +01:00
parent a09ff23ca5
commit a3abce9814
3 changed files with 7 additions and 2 deletions

View File

@ -3,6 +3,9 @@
# easy-i18n Changelog # easy-i18n Changelog
## [Unreleased] ## [Unreleased]
### Fixed
- Key focus within tree or table view after translation change
### Changed ### Changed
- update Qodana to latest version - update Qodana to latest version

View File

@ -90,8 +90,8 @@ public class TableView implements BusListener {
} }
if (row > -1) { // Matched @key if (row > -1) { // Matched @key
table.scrollRectToVisible( table.getSelectionModel().setSelectionInterval(row, row);
new Rectangle(0, (row * table.getRowHeight()) + table.getHeight(), 0, 0)); table.scrollRectToVisible(new Rectangle(table.getCellRect(row, 0, true)));
} }
} }

View File

@ -88,6 +88,8 @@ public class TreeView implements BusListener {
public void onFocusKey(@Nullable String key) { public void onFocusKey(@Nullable String key) {
if(key != null && currentMapper != null) { if(key != null && currentMapper != null) {
TreePath path = currentMapper.findTreePath(key); TreePath path = currentMapper.findTreePath(key);
this.tree.getSelectionModel().setSelectionPath(path);
this.tree.scrollPathToVisible(path); this.tree.scrollPathToVisible(path);
if(this.tree.isCollapsed(path)) { if(this.tree.isCollapsed(path)) {