Skip to content

Commit

Permalink
Fix type-ahead logic in map window. (#12690)
Browse files Browse the repository at this point in the history
This was broken when we made the list always sorted in JTable, which caused view and model indexes to not correspond. Also fixes keyPressTime logic.
  • Loading branch information
asvitkine committed Jul 4, 2024
1 parent 0ae9ca2 commit 714a2af
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public void keyPressed(KeyEvent evt) {
if (time > keyPressTime + INPUT_RESET_TIME_MS) {
inputString = "";
}
keyPressTime = keyPressTime;
keyPressTime = time;
inputString += Character.toLowerCase(ch);

final var tableModel = table.getModel();
Expand All @@ -44,8 +44,9 @@ public void keyPressed(KeyEvent evt) {
}
}

private void selectRow(int rowIndex) {
table.setRowSelectionInterval(rowIndex, rowIndex);
table.scrollRectToVisible(table.getCellRect(rowIndex, 0, true));
private void selectRow(int modelRowIndex) {
int viewRowIndex = table.getRowSorter().convertRowIndexToView(modelRowIndex);
table.setRowSelectionInterval(viewRowIndex, viewRowIndex);
table.scrollRectToVisible(table.getCellRect(viewRowIndex, 0, true));
}
}

0 comments on commit 714a2af

Please sign in to comment.