You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pivot.apache.org by rw...@apache.org on 2017/05/25 22:13:01 UTC
svn commit: r1796215 - in /pivot/trunk:
wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraTextInputSkin.java
wtk/src/org/apache/pivot/wtk/Component.java
Author: rwhitcomb
Date: Thu May 25 22:13:00 2017
New Revision: 1796215
URL: http://svn.apache.org/viewvc?rev=1796215&view=rev
Log:
PIVOT-850: Fixed a problem where backspace to completely erase text using
the input method editors would cause an exception. The solution is to clear
the "composedText" value if there was no text given with the
"inputMethodTextChanged" callback.
Also, move the calculation of screen-relative coordinates into Component.java
(with a new "offsetToScreen()" method) so it can be used in other places
shortly (namely TextArea and TextPane).
Modified:
pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraTextInputSkin.java
pivot/trunk/wtk/src/org/apache/pivot/wtk/Component.java
Modified: pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraTextInputSkin.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraTextInputSkin.java?rev=1796215&r1=1796214&r2=1796215&view=diff
==============================================================================
--- pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraTextInputSkin.java (original)
+++ pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraTextInputSkin.java Thu May 25 22:13:00 2017
@@ -156,10 +156,7 @@ System.out.format("TextInputSkin.getLoca
private Rectangle offsetToScreen(Rectangle clientRectangle) {
TextInput textInput = (TextInput)getComponent();
- Bounds screenBounds = textInput.getScreenBounds();
- Rectangle screenRect = new Rectangle(clientRectangle);
- screenRect.translate(screenBounds.x, screenBounds.y);
- return screenRect;
+ return textInput.offsetToScreen(clientRectangle);
}
@Override
@@ -207,7 +204,6 @@ System.out.format("TextInputSkin.getLoca
public void inputMethodTextChanged(InputMethodEvent event) {
TextInput textInput = (TextInput)getComponent();
AttributedCharacterIterator iter = event.getText();
- // TODO: IS THIS RIGHT?? Just ignore empty text changes
if (iter != null) {
int endOfCommittedText = event.getCommittedCharacterCount();
textInput.insertText(getCommittedText(iter, endOfCommittedText), textInput.getSelectionStart());
@@ -216,6 +212,8 @@ System.out.format("TextInputSkin.getLoca
//textInput.setSelection(endOfCommittedText, 0);
layout();
repaintComponent();
+ } else {
+ composedText = null;
}
}
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/Component.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/Component.java?rev=1796215&r1=1796214&r2=1796215&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/Component.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/Component.java Thu May 25 22:13:00 2017
@@ -1480,6 +1480,21 @@ public abstract class Component implemen
}
/**
+ * Convert and return a new {@link Rectangle} from component-relative
+ * coordinates to screen-relative. Uses the {@link #getScreenBounds}
+ * method to accomplish the mapping.
+ *
+ * @param clientRectangle A rectangle in component-relative coordinates.
+ * @return A new object in screen-relative coordinates.
+ */
+ public Rectangle offsetToScreen(Rectangle clientRectangle) {
+ Bounds screenBounds = getScreenBounds();
+ return new Rectangle(clientRectangle.x + screenBounds.x,
+ clientRectangle.y + screenBounds.y,
+ clientRectangle.width, clientRectangle.height);
+ }
+
+ /**
* Determines if the component contains a given location. This method
* facilitates mouse interaction with non-rectangular components.
*