Fixed the structure editor sometimes losing focus when editing data

types
This commit is contained in:
dragonmacher 2023-03-15 15:58:57 -04:00
parent 179f093aca
commit c7b4c69720
3 changed files with 25 additions and 13 deletions

View file

@ -940,22 +940,26 @@ public class GTable extends JTable {
public boolean editCellAt(int row, int column, EventObject e) {
boolean editAtCell = super.editCellAt(row, column, e);
if (editAtCell) {
TableCellEditor currentEditor = getCellEditor();
Component editorComponent = getEditorComponent();
if (currentEditor instanceof FocusableEditor focusable) {
focusable.focusEditor();
}
else {
editorComponent.requestFocusInWindow();
}
if (editorComponent instanceof JTextComponent textComponent) {
textComponent.selectAll();
}
requestTableFocus();
}
return editAtCell;
}
public void requestTableFocus() {
TableCellEditor currentEditor = getCellEditor();
Component editorComponent = getEditorComponent();
if (currentEditor instanceof FocusableEditor focusable) {
focusable.focusEditor();
}
else {
editorComponent.requestFocusInWindow();
}
if (editorComponent instanceof JTextComponent textComponent) {
textComponent.selectAll();
}
}
public void scrollToSelectedRow() {
int[] selectedRows = getSelectedRows();
if (selectedRows == null || selectedRows.length == 0) {