pivot-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Roger L. Whitcomb" <Roger.Whitc...@actian.com>
Subject RE: textinput cut/paste event
Date Thu, 29 Aug 2013 17:32:12 GMT
Well, the code in TextInput.paste() checks if access to the clipboard is
available and if there is any text content.  If so, it removes the
selected text (if any) and inserts the clipboard contents at the current
selection point.  Both of these events work the same as any other
delete/insert (that is, they call the listeners to check the Vote
results, and then call the listeners to notify of the change).  Here is
a little bit of the code:

 

For Remove:

    private void removeText(int index, int count, boolean
addToEditHistory) {

        if (count > 0) {

            Vote vote =
textInputContentListeners.previewRemoveText(this, index, count);

 

            if (vote == Vote.APPROVE) {

                // Add a remove history item

                if (addToEditHistory) {

                    addHistoryItem(new RemoveTextEdit(index, count));

                }

 

                // Remove the text

                characters.delete(index, index + count);

 

                // 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, index,
count);

                textInputContentListeners.textChanged(this);

 

                if (textValid != previousTextValid) {

                    textInputListeners.textValidChanged(this);

                }

 

                if (selectionStart != previousSelectionStart

                    || selectionLength != previousSelectionLength) {

                    textInputSelectionListeners.selectionChanged(this,
selectionStart, selectionLength);

                }

 

For Insert:

    private void insertText(CharSequence text, int index, boolean
addToEditHistory) {

        if (text == null) {

            throw new IllegalArgumentException();

        }

 

        if (characters.length() + text.length() > maximumLength) {

            throw new IllegalArgumentException("Insertion of text would
exceed maximum length.");

        }

 

        if (text.length() > 0) {

            Vote vote =
textInputContentListeners.previewInsertText(this, text, index);

 

            if (vote == Vote.APPROVE) {

                // Insert the text

                characters.insert(index, text);

 

                // Add an insert history item

                if (addToEditHistory) {

                    addHistoryItem(new InsertTextEdit(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());

 

                // Fire change events

                textInputContentListeners.textInserted(this, index,
text.length());

                textInputContentListeners.textChanged(this);

 

                if (textValid != previousTextValid) {

                    textInputListeners.textValidChanged(this);

                }

 

                if (selectionStart != previousSelectionStart

                    || selectionLength != previousSelectionLength) {

                    textInputSelectionListeners.selectionChanged(this,
selectionStart, selectionLength);

                }

 

                So, my guess would be (as per the other comments) that
either there is no text on the clipboard or clipboard access is disabled
somehow....

HTH,

~Roger

 

From: Schwartz, Cynthia L [mailto:cynthia.l.schwartz@intel.com] 
Sent: Thursday, August 29, 2013 10:14 AM
To: user@pivot.apache.org
Subject: RE: textinput cut/paste event

 

It is not an applet, it is a DesktopApplication.

 

C

 

From: Erik Innocent [mailto:einnocent@gmail.com] 
Sent: Thursday, August 29, 2013 10:05 AM
To: user
Subject: Re: textinput cut/paste event

 

Is this for an applet? If so, it may not have access to the system
clipboard for security reasons. See the question "Why doesn't copy/paste
work in Pivot?" here:

 

http://pivot.apache.org/faq.html

 

Cheers,

--E

 

On Thu, Aug 29, 2013 at 10:41 AM, gr8coat gr8coat
<djangologie2@gmail.com> wrote:

Hello,

 

I am pasting into a textinput and neither

 

textChanged nor

textInserted 

 

get fired.

When I type the into the textinput, the textInserted gets fired.
Wondering if there is another event that handles textinput pasting?

 

 

 


Mime
View raw message