disable standard behaviour of Mac OS X text field (i.e. select-all after focus gain) in order to make completion work more smoothly;
authorwenzelm
Tue, 24 Sep 2013 19:41:14 +0200
changeset 53848 8d7029eb0c31
parent 53847 104a08c2be9f
child 53849 a3177973ca5e
disable standard behaviour of Mac OS X text field (i.e. select-all after focus gain) in order to make completion work more smoothly;
src/Pure/GUI/gui.scala
src/Tools/jEdit/src/completion_popup.scala
--- a/src/Pure/GUI/gui.scala	Tue Sep 24 18:42:44 2013 +0200
+++ b/src/Pure/GUI/gui.scala	Tue Sep 24 19:41:14 2013 +0200
@@ -34,6 +34,9 @@
 
   def init_laf(): Unit = UIManager.setLookAndFeel(get_laf())
 
+  def is_macos_laf(): Boolean =
+    UIManager.getSystemLookAndFeelClassName() == UIManager.getLookAndFeel.getClass.getName
+
 
   /* simple dialogs */
 
--- a/src/Tools/jEdit/src/completion_popup.scala	Tue Sep 24 18:42:44 2013 +0200
+++ b/src/Tools/jEdit/src/completion_popup.scala	Tue Sep 24 19:41:14 2013 +0200
@@ -13,6 +13,7 @@
 import java.awt.event.{KeyEvent, MouseEvent, MouseAdapter, FocusAdapter, FocusEvent}
 import javax.swing.{JPanel, JComponent, JLayeredPane, SwingUtilities}
 import javax.swing.border.LineBorder
+import javax.swing.text.DefaultCaret
 
 import scala.swing.{ListView, ScrollPane}
 import scala.swing.event.MouseClicked
@@ -221,6 +222,8 @@
   {
     text_field =>
 
+    // see https://forums.oracle.com/thread/1361677
+    if (GUI.is_macos_laf) text_field.setCaret(new DefaultCaret)
 
     private var completion_popup: Option[Completion_Popup] = None