FlatLaf icon indicating copy to clipboard operation
FlatLaf copied to clipboard

'JTextField.selectAllOnFocusPolicy always' not working in tables

Open mwithake opened this issue 2 years ago • 1 comments

We have set UIManager.put("TextComponent.selectAllOnFocusPolicy", "always") for textfields. But this is not working when the component is the editor for a table-cell.

mwithake avatar Feb 22 '23 07:02 mwithake

Yes, TextComponent.selectAllOnFocusPolicy is disabled for cell editors since fixing #395 (in FlatLaf 1.6.2).

However, ATM I'm not sure whether the fix is ok. There is some difference between commit message (mentions JTable.surrendersFocusOnKeystroke) and changed code (does not use JTable.surrendersFocusOnKeystroke) 😕

I'll have a look...

DevCharly avatar Feb 23 '23 12:02 DevCharly

fixed in commit 2972300112219c88bf600b8de4cb19538e0d1d9c

DevCharly avatar Feb 19 '24 21:02 DevCharly

We have tried the new solution with UIManager.put("Table.editorSelectAllOnStartEditing", true), but is not working if you tabbed thru the cells or if the editor is an JFormattedTextField.

mwithake avatar Mar 13 '24 15:03 mwithake

We have tried the new solution with UIManager.put("Table.editorSelectAllOnStartEditing", true),

This is not necessary because it is the default.

... but is not working if you tabbed thru the cells

How do you start editing?

... or if the editor is an JFormattedTextField.

Is the selectAll() method invoked?

https://github.com/JFormDesigner/FlatLaf/blob/d26819d2684d21ea7b00c29a0e28e2e9a6799476/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTableUI.java#L627-L628

DevCharly avatar Mar 13 '24 15:03 DevCharly

Sorry for not mentioning this, we have extended JTable so that editing starts automatically for editable cells: image

selectAll() for JFormattedTextField is invoked, but i seems only for the DisplayFormat, not for the EditFormat

mwithake avatar Mar 13 '24 15:03 mwithake