You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pivot.apache.org by gb...@apache.org on 2010/08/27 14:40:52 UTC

svn commit: r990131 - in /pivot/trunk: demos/src/org/apache/pivot/demos/suggest/ tests/src/org/apache/pivot/tests/ tutorials/src/org/apache/pivot/tutorials/menus/ tutorials/src/org/apache/pivot/tutorials/stocktracker/ tutorials/src/org/apache/pivot/tut...

Author: gbrown
Date: Fri Aug 27 12:40:51 2010
New Revision: 990131

URL: http://svn.apache.org/viewvc?rev=990131&view=rev
Log:
Make text input events vetoable.

Added:
    pivot/trunk/tests/src/org/apache/pivot/tests/text_input_event_test.bxml
Modified:
    pivot/trunk/demos/src/org/apache/pivot/demos/suggest/SuggestionDemo.java
    pivot/trunk/tests/src/org/apache/pivot/tests/SuggestionPopupTest.java
    pivot/trunk/tutorials/src/org/apache/pivot/tutorials/menus/MenuBars.java
    pivot/trunk/tutorials/src/org/apache/pivot/tutorials/stocktracker/StockTrackerWindow.java
    pivot/trunk/tutorials/src/org/apache/pivot/tutorials/text/SuggestionPopups.java
    pivot/trunk/tutorials/src/org/apache/pivot/tutorials/text/TextInputs.java
    pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraFileBrowserSheetSkin.java
    pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraFileBrowserSkin.java
    pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraTextInputSkin.java
    pivot/trunk/wtk/src/org/apache/pivot/wtk/TextArea2.java
    pivot/trunk/wtk/src/org/apache/pivot/wtk/TextInput.java
    pivot/trunk/wtk/src/org/apache/pivot/wtk/TextInputContentListener.java

Modified: pivot/trunk/demos/src/org/apache/pivot/demos/suggest/SuggestionDemo.java
URL: http://svn.apache.org/viewvc/pivot/trunk/demos/src/org/apache/pivot/demos/suggest/SuggestionDemo.java?rev=990131&r1=990130&r2=990131&view=diff
==============================================================================
--- pivot/trunk/demos/src/org/apache/pivot/demos/suggest/SuggestionDemo.java (original)
+++ pivot/trunk/demos/src/org/apache/pivot/demos/suggest/SuggestionDemo.java Fri Aug 27 12:40:51 2010
@@ -53,7 +53,7 @@ public class SuggestionDemo extends Wind
         textInput = (TextInput)namespace.get("textInput");
         activityIndicator = (ActivityIndicator)namespace.get("activityIndicator");
 
-        textInput.getTextInputTextListeners().add(new TextInputContentListener.Adapter() {
+        textInput.getTextInputContentListeners().add(new TextInputContentListener.Adapter() {
             @Override
             public void textInserted(TextInput textInput, int index, int count) {
                 getSuggestions();

Modified: pivot/trunk/tests/src/org/apache/pivot/tests/SuggestionPopupTest.java
URL: http://svn.apache.org/viewvc/pivot/trunk/tests/src/org/apache/pivot/tests/SuggestionPopupTest.java?rev=990131&r1=990130&r2=990131&view=diff
==============================================================================
--- pivot/trunk/tests/src/org/apache/pivot/tests/SuggestionPopupTest.java (original)
+++ pivot/trunk/tests/src/org/apache/pivot/tests/SuggestionPopupTest.java Fri Aug 27 12:40:51 2010
@@ -45,7 +45,7 @@ public class SuggestionPopupTest impleme
             "suggestion_popup_test.bxml");
         bxmlSerializer.bind(this);
 
-        textInput.getTextInputTextListeners().add(new TextInputContentListener.Adapter() {
+        textInput.getTextInputContentListeners().add(new TextInputContentListener.Adapter() {
             @Override
             public void textInserted(TextInput textInput, int index, int count) {
                 ArrayList<String> suggestions = new ArrayList<String>("One", "Two", "Three", "Four", "Five");

Added: pivot/trunk/tests/src/org/apache/pivot/tests/text_input_event_test.bxml
URL: http://svn.apache.org/viewvc/pivot/trunk/tests/src/org/apache/pivot/tests/text_input_event_test.bxml?rev=990131&view=auto
==============================================================================
--- pivot/trunk/tests/src/org/apache/pivot/tests/text_input_event_test.bxml (added)
+++ pivot/trunk/tests/src/org/apache/pivot/tests/text_input_event_test.bxml Fri Aug 27 12:40:51 2010
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to you under the Apache License,
+Version 2.0 (the "License"); you may not use this file except in
+compliance with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+-->
+
+<Window title="TextInput Event Test" maximized="true"
+    xmlns:bxml="http://pivot.apache.org/bxml"
+    xmlns="org.apache.pivot.wtk">
+    <BoxPane orientation="vertical">
+        <TextInput bxml:id="textInput">
+            <textInputContentListeners>
+            importClass(org.apache.pivot.util.Vote);
+
+            function previewInsertText(textInput, text, index) {
+                return (text == "e") ? Vote.DENY : Vote.APPROVE;
+            }
+
+            function previewRemoveText(textInput, index, count) {
+                var text = textInput.characters.subSequence(index, index + count).toString();
+                return (text == "f") ? Vote.DENY : Vote.APPROVE;
+            }
+            </textInputContentListeners>
+        </TextInput>
+    </BoxPane>
+</Window>

Modified: pivot/trunk/tutorials/src/org/apache/pivot/tutorials/menus/MenuBars.java
URL: http://svn.apache.org/viewvc/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/menus/MenuBars.java?rev=990131&r1=990130&r2=990131&view=diff
==============================================================================
--- pivot/trunk/tutorials/src/org/apache/pivot/tutorials/menus/MenuBars.java (original)
+++ pivot/trunk/tutorials/src/org/apache/pivot/tutorials/menus/MenuBars.java Fri Aug 27 12:40:51 2010
@@ -65,7 +65,7 @@ public class MenuBars extends Frame impl
                 updateActionState(textInput);
                 Action.getNamedActions().get("paste").setEnabled(true);
 
-                textInput.getTextInputTextListeners().add(textInputTextListener);
+                textInput.getTextInputContentListeners().add(textInputTextListener);
                 textInput.getTextInputSelectionListeners().add(textInputSelectionListener);
             } else {
                 Action.getNamedActions().get("cut").setEnabled(false);
@@ -78,7 +78,7 @@ public class MenuBars extends Frame impl
         public void cleanupMenuBar(Component component, MenuBar menuBar) {
             if (component instanceof TextInput) {
                 TextInput textInput = (TextInput)component;
-                textInput.getTextInputTextListeners().remove(textInputTextListener);
+                textInput.getTextInputContentListeners().remove(textInputTextListener);
                 textInput.getTextInputSelectionListeners().remove(textInputSelectionListener);
             }
         }

Modified: pivot/trunk/tutorials/src/org/apache/pivot/tutorials/stocktracker/StockTrackerWindow.java
URL: http://svn.apache.org/viewvc/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/stocktracker/StockTrackerWindow.java?rev=990131&r1=990130&r2=990131&view=diff
==============================================================================
--- pivot/trunk/tutorials/src/org/apache/pivot/tutorials/stocktracker/StockTrackerWindow.java (original)
+++ pivot/trunk/tutorials/src/org/apache/pivot/tutorials/stocktracker/StockTrackerWindow.java Fri Aug 27 12:40:51 2010
@@ -209,7 +209,7 @@ public class StockTrackerWindow extends 
         });
 
         // Add symbol text input event handlers
-        symbolTextInput.getTextInputTextListeners().add(new TextInputContentListener.Adapter() {
+        symbolTextInput.getTextInputContentListeners().add(new TextInputContentListener.Adapter() {
             @Override
             public void textChanged(TextInput textInput) {
                 addSymbolAction.setEnabled(textInput.getCharacters().length() > 0);

Modified: pivot/trunk/tutorials/src/org/apache/pivot/tutorials/text/SuggestionPopups.java
URL: http://svn.apache.org/viewvc/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/text/SuggestionPopups.java?rev=990131&r1=990130&r2=990131&view=diff
==============================================================================
--- pivot/trunk/tutorials/src/org/apache/pivot/tutorials/text/SuggestionPopups.java (original)
+++ pivot/trunk/tutorials/src/org/apache/pivot/tutorials/text/SuggestionPopups.java Fri Aug 27 12:40:51 2010
@@ -95,7 +95,7 @@ public class SuggestionPopups extends Wi
     @Override
     public void initialize(Map<String, Object> namespace, URL location, Resources resources) {
         stateTextInput = (TextInput)namespace.get("stateTextInput");
-        stateTextInput.getTextInputTextListeners().add(new TextInputContentListener.Adapter() {
+        stateTextInput.getTextInputContentListeners().add(new TextInputContentListener.Adapter() {
             @Override
             public void textInserted(TextInput textInput, int index, int count) {
                 String text = textInput.getText();

Modified: pivot/trunk/tutorials/src/org/apache/pivot/tutorials/text/TextInputs.java
URL: http://svn.apache.org/viewvc/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/text/TextInputs.java?rev=990131&r1=990130&r2=990131&view=diff
==============================================================================
--- pivot/trunk/tutorials/src/org/apache/pivot/tutorials/text/TextInputs.java (original)
+++ pivot/trunk/tutorials/src/org/apache/pivot/tutorials/text/TextInputs.java Fri Aug 27 12:40:51 2010
@@ -93,7 +93,7 @@ public class TextInputs extends Window i
     @Override
     public void initialize(Map<String, Object> namespace, URL location, Resources resources) {
         stateTextInput = (TextInput)namespace.get("stateTextInput");
-        stateTextInput.getTextInputTextListeners().add(new TextInputContentListener.Adapter() {
+        stateTextInput.getTextInputContentListeners().add(new TextInputContentListener.Adapter() {
             @Override
             public void textInserted(final TextInput textInput, int index, int count) {
                 String text = textInput.getText();

Modified: pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraFileBrowserSheetSkin.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraFileBrowserSheetSkin.java?rev=990131&r1=990130&r2=990131&view=diff
==============================================================================
--- pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraFileBrowserSheetSkin.java (original)
+++ pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraFileBrowserSheetSkin.java Fri Aug 27 12:40:51 2010
@@ -100,7 +100,7 @@ public class TerraFileBrowserSheetSkin e
 
         bxmlSerializer.bind(this, TerraFileBrowserSheetSkin.class);
 
-        saveAsTextInput.getTextInputTextListeners().add(new TextInputContentListener.Adapter() {
+        saveAsTextInput.getTextInputContentListeners().add(new TextInputContentListener.Adapter() {
             @Override
             public void textChanged(TextInput textInput) {
                 updateOKButtonState();

Modified: pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraFileBrowserSkin.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraFileBrowserSkin.java?rev=990131&r1=990130&r2=990131&view=diff
==============================================================================
--- pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraFileBrowserSkin.java (original)
+++ pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraFileBrowserSkin.java Fri Aug 27 12:40:51 2010
@@ -649,7 +649,7 @@ public class TerraFileBrowserSkin extend
             }
         });
 
-        searchTextInput.getTextInputTextListeners().add(new TextInputContentListener.Adapter() {
+        searchTextInput.getTextInputContentListeners().add(new TextInputContentListener.Adapter() {
             @Override
             public void textChanged(TextInput textInput) {
                 String text = textInput.getText().trim();

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=990131&r1=990130&r2=990131&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 Fri Aug 27 12:40:51 2010
@@ -33,6 +33,7 @@ import java.text.CharacterIterator;
 
 import org.apache.pivot.collections.Dictionary;
 import org.apache.pivot.text.CharSequenceCharacterIterator;
+import org.apache.pivot.util.Vote;
 import org.apache.pivot.wtk.ApplicationContext;
 import org.apache.pivot.wtk.Bounds;
 import org.apache.pivot.wtk.Component;
@@ -182,7 +183,7 @@ public class TerraTextInputSkin extends 
 
         TextInput textInput = (TextInput)component;
         textInput.getTextInputListeners().add(this);
-        textInput.getTextInputTextListeners().add(this);
+        textInput.getTextInputContentListeners().add(this);
         textInput.getTextInputSelectionListeners().add(this);
 
         textInput.setCursor(Cursor.TEXT);
@@ -1294,11 +1295,31 @@ public class TerraTextInputSkin extends 
 
     // Text input character events
     @Override
+    public Vote previewInsertText(TextInput textInput, String text, int index) {
+        return Vote.APPROVE;
+    }
+
+    @Override
+    public void insertTextVetoed(TextInput textInput, Vote reason) {
+        // No-op
+    }
+
+    @Override
     public void textInserted(TextInput textInput, int index, int count) {
         // No-op
     }
 
     @Override
+    public Vote previewRemoveText(TextInput textInput, int index, int count) {
+        return Vote.APPROVE;
+    }
+
+    @Override
+    public void removeTextVetoed(TextInput textInput, Vote reason) {
+        // No-op
+    }
+
+    @Override
     public void textRemoved(TextInput textInput, int index, int count) {
         // No-op
     }

Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/TextArea2.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/TextArea2.java?rev=990131&r1=990130&r2=990131&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/TextArea2.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/TextArea2.java Fri Aug 27 12:40:51 2010
@@ -536,7 +536,7 @@ public class TextArea2 extends Component
         return textAreaListeners;
     }
 
-    public ListenerList<TextAreaContentListener2> getTextAreaCharacterListeners() {
+    public ListenerList<TextAreaContentListener2> getTextAreaContentListeners() {
         return textAreaContentListeners;
     }
 

Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/TextInput.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/TextInput.java?rev=990131&r1=990130&r2=990131&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/TextInput.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/TextInput.java Fri Aug 27 12:40:51 2010
@@ -21,6 +21,7 @@ import java.io.IOException;
 
 import org.apache.pivot.json.JSON;
 import org.apache.pivot.util.ListenerList;
+import org.apache.pivot.util.Vote;
 import org.apache.pivot.wtk.validation.Validator;
 
 /**
@@ -123,6 +124,24 @@ public class TextInput extends Component
     private static class TextInputContentListenerList extends ListenerList<TextInputContentListener>
         implements TextInputContentListener {
         @Override
+        public Vote previewInsertText(TextInput textInput, String text, int index) {
+            Vote vote = Vote.APPROVE;
+
+            for (TextInputContentListener listener : this) {
+                vote = vote.tally(listener.previewInsertText(textInput, text, index));
+            }
+
+            return vote;
+        }
+
+        @Override
+        public void insertTextVetoed(TextInput textInput, Vote reason) {
+            for (TextInputContentListener listener : this) {
+                listener.insertTextVetoed(textInput, reason);
+            }
+        }
+
+        @Override
         public void textInserted(TextInput textInput, int index, int count) {
             for (TextInputContentListener listener : this) {
                 listener.textInserted(textInput, index, count);
@@ -130,6 +149,24 @@ public class TextInput extends Component
         }
 
         @Override
+        public Vote previewRemoveText(TextInput textInput, int index, int count) {
+            Vote vote = Vote.APPROVE;
+
+            for (TextInputContentListener listener : this) {
+                vote = vote.tally(listener.previewRemoveText(textInput, index, count));
+            }
+
+            return vote;
+        }
+
+        @Override
+        public void removeTextVetoed(TextInput textInput, Vote reason) {
+            for (TextInputContentListener listener : this) {
+                listener.removeTextVetoed(textInput, reason);
+            }
+        }
+
+        @Override
         public void textRemoved(TextInput textInput, int index, int count) {
             for (TextInputContentListener listener : this) {
                 listener.textRemoved(textInput, index, count);
@@ -271,29 +308,35 @@ public class TextInput extends Component
 
         // Insert the text
         if (text.length() > 0) {
-            characters.insert(selectionStart, text);
+            Vote vote = textInputContentListeners.previewInsertText(this, text, index);
 
-            // Update selection
-            int previousSelectionStart = selectionStart;
-            int previousSelectionLength = selectionLength;
-            selectionStart = index + text.length();
-            selectionLength = 0;
-
-            // Update the valid flag
-            boolean previousTextValid = textValid;
-            textValid = (validator == null) ? true : validator.isValid(getText());
+            if (vote == Vote.APPROVE) {
+                characters.insert(selectionStart, text);
 
-            // Fire change events
-            textInputContentListeners.textInserted(this, previousSelectionStart, text.length());
-            textInputContentListeners.textChanged(this);
+                // Update selection
+                int previousSelectionStart = selectionStart;
+                int previousSelectionLength = selectionLength;
+                selectionStart = index + text.length();
+                selectionLength = 0;
+
+                // Update the valid flag
+                boolean previousTextValid = textValid;
+                textValid = (validator == null) ? true : validator.isValid(getText());
+
+                // Fire change events
+                textInputContentListeners.textInserted(this, previousSelectionStart, text.length());
+                textInputContentListeners.textChanged(this);
 
-            if (textValid != previousTextValid) {
-                textInputListeners.textValidChanged(this);
-            }
+                if (textValid != previousTextValid) {
+                    textInputListeners.textValidChanged(this);
+                }
 
-            if (selectionStart != previousSelectionStart
-                || selectionLength != previousSelectionLength) {
-                textInputSelectionListeners.selectionChanged(this, selectionStart, selectionLength);
+                if (selectionStart != previousSelectionStart
+                    || selectionLength != previousSelectionLength) {
+                    textInputSelectionListeners.selectionChanged(this, selectionStart, selectionLength);
+                }
+            } else {
+                textInputContentListeners.insertTextVetoed(this, vote);
             }
         }
     }
@@ -301,29 +344,35 @@ public class TextInput extends Component
     public void removeText(int index, int count) {
         // Remove the text
         if (count > 0) {
-            characters.delete(index, index + count);
+            Vote vote = textInputContentListeners.previewRemoveText(this, index, count);
 
-            // Update the selection
-            int previousSelectionStart = selectionStart;
-            int previousSelectionLength = selectionLength;
-            selectionStart = index;
-            selectionLength = 0;
+            if (vote == Vote.APPROVE) {
+                characters.delete(index, index + count);
 
-            // Update the valid flag
-            boolean previousTextValid = textValid;
-            textValid = (validator == null) ? true : validator.isValid(getText());
+                // Update the selection
+                int previousSelectionStart = selectionStart;
+                int previousSelectionLength = selectionLength;
+                selectionStart = index;
+                selectionLength = 0;
+
+                // Update the valid flag
+                boolean previousTextValid = textValid;
+                textValid = (validator == null) ? true : validator.isValid(getText());
+
+                // Fire change events
+                textInputContentListeners.textRemoved(this, selectionStart, count);
+                textInputContentListeners.textChanged(this);
 
-            // Fire change events
-            textInputContentListeners.textRemoved(this, selectionStart, count);
-            textInputContentListeners.textChanged(this);
-
-            if (textValid != previousTextValid) {
-                textInputListeners.textValidChanged(this);
-            }
+                if (textValid != previousTextValid) {
+                    textInputListeners.textValidChanged(this);
+                }
 
-            if (selectionStart != previousSelectionStart
-                || selectionLength != previousSelectionLength) {
-                textInputSelectionListeners.selectionChanged(this, selectionStart, selectionLength);
+                if (selectionStart != previousSelectionStart
+                    || selectionLength != previousSelectionLength) {
+                    textInputSelectionListeners.selectionChanged(this, selectionStart, selectionLength);
+                }
+            } else {
+                textInputContentListeners.removeTextVetoed(this, vote);
             }
         }
     }
@@ -764,7 +813,7 @@ public class TextInput extends Component
     /**
      * Returns the text input text listener list.
      */
-    public ListenerList<TextInputContentListener> getTextInputTextListeners() {
+    public ListenerList<TextInputContentListener> getTextInputContentListeners() {
         return textInputContentListeners;
     }
 

Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/TextInputContentListener.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/TextInputContentListener.java?rev=990131&r1=990130&r2=990131&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/TextInputContentListener.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/TextInputContentListener.java Fri Aug 27 12:40:51 2010
@@ -16,6 +16,8 @@
  */
 package org.apache.pivot.wtk;
 
+import org.apache.pivot.util.Vote;
+
 /**
  * Text input text listener.
  */
@@ -25,10 +27,28 @@ public interface TextInputContentListene
      */
     public static class Adapter implements TextInputContentListener {
         @Override
+        public Vote previewInsertText(TextInput textInput, String text, int index) {
+            return Vote.APPROVE;
+        }
+
+        @Override
+        public void insertTextVetoed(TextInput textInput, Vote reason) {
+        }
+
+        @Override
         public void textInserted(TextInput textInput, int index, int count) {
         }
 
         @Override
+        public Vote previewRemoveText(TextInput textInput, int index, int count) {
+            return Vote.APPROVE;
+        }
+
+        @Override
+        public void removeTextVetoed(TextInput textInput, Vote reason) {
+        }
+
+        @Override
         public void textRemoved(TextInput textInput, int index, int count) {
         }
 
@@ -38,6 +58,31 @@ public interface TextInputContentListene
     }
 
     /**
+     * Called to preview a text insertion.
+     *
+     * @param textInput
+     * The source of the event.
+     *
+     * @param text
+     * The text that will be inserted.
+     *
+     * @param index
+     * The index at which the text will be inserted.
+     */
+    public Vote previewInsertText(TextInput textInput, String text, int index);
+
+    /**
+     * Called when a text insertion has been vetoed.
+     *
+     * @param textInput
+     * The source of the event.
+     *
+     * @param reason
+     * The reason the event was vetoed.
+     */
+    public void insertTextVetoed(TextInput textInput, Vote reason);
+
+    /**
      * Called when text has been inserted into a text input.
      *
      * @param textInput
@@ -52,6 +97,28 @@ public interface TextInputContentListene
     public void textInserted(TextInput textInput, int index, int count);
 
     /**
+     * Called to preview a text removal.
+     *
+     * @param textInput
+     * The source of the event.
+     *
+     * @param index
+     * The starting index from which the text will be removed.
+     */
+    public Vote previewRemoveText(TextInput textInput, int index, int count);
+
+    /**
+     * Called when a text removal has been vetoed.
+     *
+     * @param textInput
+     * The source of the event.
+     *
+     * @param reason
+     * The reason the event was vetoed.
+     */
+    public void removeTextVetoed(TextInput textInput, Vote reason);
+
+    /**
      * Called when text has been removed from a text input.
      *
      * @param textInput