Mercurial Hosting > luan
changeset 1968:2ea6ab849e1a default tip
text area focus handling
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Tue, 10 Jun 2025 19:36:11 -0600 |
parents | b35e1ccac1bb |
children | |
files | src/luan/modules/swing/TextAreaLuan.java |
diffstat | 1 files changed, 9 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/luan/modules/swing/TextAreaLuan.java Tue Jun 10 18:42:46 2025 -0600 +++ b/src/luan/modules/swing/TextAreaLuan.java Tue Jun 10 19:36:11 2025 -0600 @@ -10,6 +10,7 @@ import java.awt.event.FocusEvent; import java.awt.event.ActionListener; import java.awt.event.ActionEvent; +import java.awt.event.MouseEvent; import javax.swing.JTextArea; import javax.swing.UIManager; import javax.swing.Timer; @@ -208,6 +209,14 @@ actions.put( DefaultEditorKit.endLineAction, endParagraphAction ); } + @Override protected void processMouseEvent(MouseEvent event) { + if( event.getID() == MouseEvent.MOUSE_PRESSED && event.getButton() == MouseEvent.BUTTON1 && !hasFocus() ) { + requestFocusInWindow(); + return; + } + super.processMouseEvent(event); + } + @Override public void updateUI() { super.updateUI(); if (UIManager.getLookAndFeel().getName().startsWith("FlatLaf")) {