mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-177568 Weird mouse selection
This commit is contained in:
+7
-4
@@ -17,14 +17,12 @@ package com.intellij.ide.ui.laf.darcula.ui;
|
|||||||
|
|
||||||
import com.intellij.ide.ui.laf.darcula.DarculaUIUtil;
|
import com.intellij.ide.ui.laf.darcula.DarculaUIUtil;
|
||||||
import com.intellij.openapi.util.SystemInfo;
|
import com.intellij.openapi.util.SystemInfo;
|
||||||
|
import com.intellij.openapi.util.registry.Registry;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import javax.swing.plaf.ComponentUI;
|
import javax.swing.plaf.ComponentUI;
|
||||||
import javax.swing.plaf.basic.BasicTextAreaUI;
|
import javax.swing.plaf.basic.BasicTextAreaUI;
|
||||||
import javax.swing.text.BadLocationException;
|
import javax.swing.text.*;
|
||||||
import javax.swing.text.DefaultEditorKit;
|
|
||||||
import javax.swing.text.JTextComponent;
|
|
||||||
import javax.swing.text.Position;
|
|
||||||
import java.awt.event.KeyEvent;
|
import java.awt.event.KeyEvent;
|
||||||
|
|
||||||
public class DarculaTextAreaUI extends BasicTextAreaUI{
|
public class DarculaTextAreaUI extends BasicTextAreaUI{
|
||||||
@@ -51,4 +49,9 @@ public class DarculaTextAreaUI extends BasicTextAreaUI{
|
|||||||
int position = DarculaUIUtil.getPatchedNextVisualPositionFrom(t, pos, direction);
|
int position = DarculaUIUtil.getPatchedNextVisualPositionFrom(t, pos, direction);
|
||||||
return position != -1 ? position : super.getNextVisualPositionFrom(t, pos, b, direction, biasRet);
|
return position != -1 ? position : super.getNextVisualPositionFrom(t, pos, b, direction, biasRet);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Caret createCaret() {
|
||||||
|
return Registry.is("ide.text.mouse.selection.new") ? new TextFieldWithPopupHandlerUI.MyCaret(getComponent()) : super.createCaret();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+26
-4
@@ -36,10 +36,7 @@ import javax.swing.event.DocumentListener;
|
|||||||
import javax.swing.plaf.FontUIResource;
|
import javax.swing.plaf.FontUIResource;
|
||||||
import javax.swing.plaf.UIResource;
|
import javax.swing.plaf.UIResource;
|
||||||
import javax.swing.plaf.basic.BasicTextFieldUI;
|
import javax.swing.plaf.basic.BasicTextFieldUI;
|
||||||
import javax.swing.text.BadLocationException;
|
import javax.swing.text.*;
|
||||||
import javax.swing.text.Document;
|
|
||||||
import javax.swing.text.JTextComponent;
|
|
||||||
import javax.swing.text.Position;
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.awt.event.*;
|
import java.awt.event.*;
|
||||||
import java.beans.PropertyChangeEvent;
|
import java.beans.PropertyChangeEvent;
|
||||||
@@ -201,6 +198,11 @@ public abstract class TextFieldWithPopupHandlerUI extends BasicTextFieldUI imple
|
|||||||
return position != -1 ? position : super.getNextVisualPositionFrom(t, pos, b, direction, biasRet);
|
return position != -1 ? position : super.getNextVisualPositionFrom(t, pos, b, direction, biasRet);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Caret createCaret() {
|
||||||
|
return Registry.is("ide.text.mouse.selection.new") ? new MyCaret(getComponent()) : super.createCaret();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean value(Object o) {
|
public boolean value(Object o) {
|
||||||
if (o instanceof MouseEvent) {
|
if (o instanceof MouseEvent) {
|
||||||
@@ -632,4 +634,24 @@ public abstract class TextFieldWithPopupHandlerUI extends BasicTextFieldUI imple
|
|||||||
return "clear";
|
return "clear";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static class MyCaret extends BasicCaret {
|
||||||
|
private final JTextComponent myComponent;
|
||||||
|
|
||||||
|
public MyCaret(JTextComponent component) {
|
||||||
|
myComponent = component;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void mouseDragged(MouseEvent e) {
|
||||||
|
if (e.getID() == MouseEvent.MOUSE_DRAGGED && !myComponent.getText().contains("\n")) {
|
||||||
|
boolean consumed = e.isConsumed();
|
||||||
|
e = new MouseEvent(e.getComponent(), e.getID(), e.getWhen(), e.getModifiers() | e.getModifiersEx(), e.getX(),
|
||||||
|
myComponent.getHeight() / 2,
|
||||||
|
e.getClickCount(), e.isPopupTrigger(), e.getButton());
|
||||||
|
if (consumed) e.consume();
|
||||||
|
}
|
||||||
|
super.mouseDragged(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1079,6 +1079,8 @@ ide.text.effect.new.scale=true
|
|||||||
ide.text.effect.new.scale.description=Enables scalable effect painter for text
|
ide.text.effect.new.scale.description=Enables scalable effect painter for text
|
||||||
ide.text.effect.new.metrics=true
|
ide.text.effect.new.metrics=true
|
||||||
ide.text.effect.new.metrics.description=Use line metrics to calculate text offset in the effect painter
|
ide.text.effect.new.metrics.description=Use line metrics to calculate text offset in the effect painter
|
||||||
|
ide.text.mouse.selection.new=true
|
||||||
|
ide.text.mouse.selection.description=Use improved mouse-drag processing in single-line text components when mouse pointer is out of area
|
||||||
|
|
||||||
ide.intellij.laf.win10.ui=true
|
ide.intellij.laf.win10.ui=true
|
||||||
ide.intellij.laf.win10.restartRequired=true
|
ide.intellij.laf.win10.restartRequired=true
|
||||||
|
|||||||
Reference in New Issue
Block a user