Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTom Schindl2015-06-16 04:49:53 -0400
committerTom Schindl2015-06-16 04:49:53 -0400
commit841fec9a098b99de673f6b79d8072c7986e02efe (patch)
tree9ab57e63b192a8708464f849feac9ce4b63e126b
parentdb4db0b35413b299e658a8a6a58836d47803d2b0 (diff)
downloadorg.eclipse.efxclipse-maint_1_3_x.tar.gz
org.eclipse.efxclipse-maint_1_3_x.tar.xz
org.eclipse.efxclipse-maint_1_3_x.zip
* fixed c&p when not editablemaint_1_3_x
* fixed IAE when calling setText("")
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/styledtext/DefaultContent.java2
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/styledtext/StyledTextArea.java27
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/styledtext/behavior/StyledTextBehavior.java13
3 files changed, 25 insertions, 17 deletions
diff --git a/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/styledtext/DefaultContent.java b/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/styledtext/DefaultContent.java
index cd75199fc..adf665289 100644
--- a/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/styledtext/DefaultContent.java
+++ b/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/styledtext/DefaultContent.java
@@ -907,7 +907,7 @@ class DefaultContent implements StyledTextContent {
TextChangedEvent textSet = TextChangedEvent.textSet(this);
for (TextChangeListener l : this.textListeners) {
- l.textChanged(textSet);
+ l.textSet(textSet);
}
}
diff --git a/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/styledtext/StyledTextArea.java b/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/styledtext/StyledTextArea.java
index bbc84daf0..f76c37da4 100644
--- a/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/styledtext/StyledTextArea.java
+++ b/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/styledtext/StyledTextArea.java
@@ -130,15 +130,15 @@ public class StyledTextArea extends Control {
private int lastTextChangeStart;
- private int lastTextChangeNewLineCount;
+// private int lastTextChangeNewLineCount;
private int lastTextChangeNewCharCount;
- private int lastTextChangeReplaceLineCount;
+// private int lastTextChangeReplaceLineCount;
private int lastTextChangeReplaceCharCount;
- private int lastCharCount;
+// private int lastCharCount;
/**
* Create a new control
@@ -158,14 +158,15 @@ public class StyledTextArea extends Control {
// }
void handleTextChanging(TextChangingEvent event) {
+ System.err.println("CHANGING: " + event);
if (event.replaceCharCount < 0) {
event.offset += event.replaceCharCount;
event.replaceCharCount *= -1;
}
this.lastTextChangeStart = event.offset;
- this.lastTextChangeNewLineCount = event.newLineCount;
+// this.lastTextChangeNewLineCount = event.newLineCount;
this.lastTextChangeNewCharCount = event.newCharCount;
- this.lastTextChangeReplaceLineCount = event.replaceLineCount;
+// this.lastTextChangeReplaceLineCount = event.replaceLineCount;
this.lastTextChangeReplaceCharCount = event.replaceCharCount;
this.renderer.textChanging(event);
@@ -180,20 +181,27 @@ public class StyledTextArea extends Control {
void handleTextSet(TextChangedEvent event) {
int newCharCount = getCharCount();
- this.lastCharCount = newCharCount;
+// this.lastCharCount = newCharCount;
+ if( this.caretOffsetProperty.get() > newCharCount ) {
+ setSelection(new TextSelection(newCharCount, 0));
+ }
+
+ if (getSkin() instanceof StyledTextSkin) {
+ ((StyledTextSkin) getSkin()).recalculateItems();
+ }
}
void handleTextChanged(TextChangedEvent event) {
// int firstLine = getContent().getLineAtOffset(lastTextChangeStart);
-
+
if (getSkin() instanceof StyledTextSkin) {
((StyledTextSkin) getSkin()).recalculateItems();
}
updateSelection(this.lastTextChangeStart, this.lastTextChangeReplaceCharCount, this.lastTextChangeNewCharCount);
- this.lastCharCount += this.lastTextChangeNewCharCount;
- this.lastCharCount -= this.lastTextChangeReplaceCharCount;
+// this.lastCharCount += this.lastTextChangeNewCharCount;
+// this.lastCharCount -= this.lastTextChangeReplaceCharCount;
}
void updateSelection(int startOffset, int replacedLength, int newLength) {
@@ -1390,6 +1398,7 @@ public class StyledTextArea extends Control {
*/
public void setSelection(@NonNull TextSelection selection) {
if (selection.length == 0) {
+ System.err.println("SETTING OFFSET: " + selection.offset);
setCaretOffset(selection.offset);
} else {
// this.caretOffsetProperty.set(selection.offset+selection.length);
diff --git a/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/styledtext/behavior/StyledTextBehavior.java b/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/styledtext/behavior/StyledTextBehavior.java
index 2de97ba55..b8198ded0 100644
--- a/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/styledtext/behavior/StyledTextBehavior.java
+++ b/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/styledtext/behavior/StyledTextBehavior.java
@@ -261,14 +261,13 @@ public class StyledTextBehavior extends BehaviorBase<StyledTextArea> {
break;
}
}
- case C:
- if( getControl().getEditable() ) {
- if( event.isShortcutDown() ) {
- getControl().copy();
- event.consume();
- break;
- }
+ case C: {
+ if( event.isShortcutDown() ) {
+ getControl().copy();
+ event.consume();
+ break;
}
+ }
default:
if( getControl().getEditable() ) {
String text = event.getText();

Back to the top