mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2025-12-08 06:50:56 +03:00
Merge pull request #202 into master
TextField: allow select all on mouse click
This commit is contained in:
@@ -36,13 +36,15 @@ public class FlatCaret
|
||||
implements UIResource
|
||||
{
|
||||
private final String selectAllOnFocusPolicy;
|
||||
private final boolean selectAllOnMouseClick;
|
||||
|
||||
private boolean wasFocused;
|
||||
private boolean wasTemporaryLost;
|
||||
private boolean isMousePressed;
|
||||
|
||||
public FlatCaret( String selectAllOnFocusPolicy ) {
|
||||
public FlatCaret( String selectAllOnFocusPolicy, boolean selectAllOnMouseClick ) {
|
||||
this.selectAllOnFocusPolicy = selectAllOnFocusPolicy;
|
||||
this.selectAllOnMouseClick = selectAllOnMouseClick;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -61,7 +63,7 @@ public class FlatCaret
|
||||
|
||||
@Override
|
||||
public void focusGained( FocusEvent e ) {
|
||||
if( !wasTemporaryLost && !isMousePressed )
|
||||
if( !wasTemporaryLost && (!isMousePressed || selectAllOnMouseClick) )
|
||||
selectAllOnFocusGained();
|
||||
wasTemporaryLost = false;
|
||||
wasFocused = true;
|
||||
|
||||
@@ -45,6 +45,7 @@ import javax.swing.plaf.ComponentUI;
|
||||
* @uiDefault Component.isIntelliJTheme boolean
|
||||
* @uiDefault FormattedTextField.placeholderForeground Color
|
||||
* @uiDefault TextComponent.selectAllOnFocusPolicy String never, once (default) or always
|
||||
* @uiDefault TextComponent.selectAllOnMouseClick boolean
|
||||
*
|
||||
* @author Karl Tauber
|
||||
*/
|
||||
|
||||
@@ -63,6 +63,7 @@ import com.formdev.flatlaf.util.HiDPIUtils;
|
||||
* @uiDefault PasswordField.showCapsLock boolean
|
||||
* @uiDefault PasswordField.capsLockIcon Icon
|
||||
* @uiDefault TextComponent.selectAllOnFocusPolicy String never, once (default) or always
|
||||
* @uiDefault TextComponent.selectAllOnMouseClick boolean
|
||||
*
|
||||
* @author Karl Tauber
|
||||
*/
|
||||
@@ -144,7 +145,8 @@ public class FlatPasswordFieldUI
|
||||
|
||||
@Override
|
||||
protected Caret createCaret() {
|
||||
return new FlatCaret( UIManager.getString( "TextComponent.selectAllOnFocusPolicy" ) );
|
||||
return new FlatCaret( UIManager.getString( "TextComponent.selectAllOnFocusPolicy" ),
|
||||
UIManager.getBoolean( "TextComponent.selectAllOnMouseClick" ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -64,6 +64,7 @@ import com.formdev.flatlaf.util.HiDPIUtils;
|
||||
* @uiDefault Component.isIntelliJTheme boolean
|
||||
* @uiDefault TextField.placeholderForeground Color
|
||||
* @uiDefault TextComponent.selectAllOnFocusPolicy String never, once (default) or always
|
||||
* @uiDefault TextComponent.selectAllOnMouseClick boolean
|
||||
*
|
||||
* @author Karl Tauber
|
||||
*/
|
||||
@@ -121,7 +122,8 @@ public class FlatTextFieldUI
|
||||
|
||||
@Override
|
||||
protected Caret createCaret() {
|
||||
return new FlatCaret( UIManager.getString( "TextComponent.selectAllOnFocusPolicy" ) );
|
||||
return new FlatCaret( UIManager.getString( "TextComponent.selectAllOnFocusPolicy"),
|
||||
UIManager.getBoolean( "TextComponent.selectAllOnMouseClick" ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -614,6 +614,7 @@ TextArea.background=@textComponentBackground
|
||||
|
||||
# allowed values: "never", "once" (default) or "always"
|
||||
TextComponent.selectAllOnFocusPolicy=once
|
||||
TextComponent.selectAllOnMouseClick=false
|
||||
TextComponent.arc=0
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user