textinput cut/paste event

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

textinput cut/paste event

gr8coat
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?


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: textinput cut/paste event

Erik Innocent
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:


Cheers,
--E


On Thu, Aug 29, 2013 at 10:41 AM, gr8coat gr8coat <[hidden email]> 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?



Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: textinput cut/paste event

Schwartz, Cynthia L

It is not an applet, it is a DesktopApplication.

 

C

 

From: Erik Innocent [mailto:[hidden email]]
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:

 

 

Cheers,

--E

 

On Thu, Aug 29, 2013 at 10:41 AM, gr8coat gr8coat <[hidden email]> 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?

 

 

 

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: textinput cut/paste event

Roger Whitcomb-2

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:[hidden email]]
Sent: Thursday, August 29, 2013 10:14 AM
To: [hidden email]
Subject: RE: textinput cut/paste event

 

It is not an applet, it is a DesktopApplication.

 

C

 

From: Erik Innocent [[hidden email]]
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:

 

 

Cheers,

--E

 

On Thu, Aug 29, 2013 at 10:41 AM, gr8coat gr8coat <[hidden email]> 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?

 

 

 

Loading...