提交 8db22869 编写于 作者: S serb

7124528: [macosx] Selection is not cleared properly in text component.

Reviewed-by: anthony, art
上级 b0c58191
......@@ -31,6 +31,7 @@ import java.awt.Point;
import java.awt.TextField;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.FocusEvent;
import java.awt.peer.TextFieldPeer;
import javax.swing.JPasswordField;
......@@ -97,6 +98,21 @@ final class LWTextFieldPeer
getText(), e.getWhen(), e.getModifiers()));
}
/**
* Restoring native behavior. We should sets the selection range to zero,
* when component lost its focus.
*
* @param e the focus event
*/
@Override
protected void handleJavaFocusEvent(final FocusEvent e) {
if (e.getID() == FocusEvent.FOCUS_LOST) {
// In order to de-select the selection
setCaretPosition(0);
}
super.handleJavaFocusEvent(e);
}
private final class JTextAreaDelegate extends JPasswordField {
// Empty non private constructor was added because access to this
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册