Highlighted

Unable to prevent default when pasting into TextField with AIR 14

Community Beginner ,
Jun 13, 2014

Copy link to clipboard

Copied

Hi,

Up until AIR 14 I was able to prevent the default behavior when pressing ctrl+v in a TextField with Air for Desktop. This allowed me to 'intercept' the pasted text and process it (removing junk markup from MS Word, but retaining some formatting) before adding it into the text field.

Now with AIR 14 calling preventDefault on the KEY_DOWN event on the TextField no longer prevents the paste action. Has anyone else experienced this? Since the TextField doesn't fire a PASTE event I have found no other way to prevent default pasting. I have filed a bug report here:

Bug#3775354 - Unable to prevent default when pasting into TextField with AIR 14

I looked at the change log for AIR 14 and there appears to be a bug fix for ctrl+v/c/x with StageText (which falls back to TextField on desktop). I wonder if this change has something to do with it? This pretty much breaks my entire application so I hope this can get resolved soon!

Thanks.

TOPICS
Performance issues

Views

547

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Unable to prevent default when pasting into TextField with AIR 14

Community Beginner ,
Jun 13, 2014

Copy link to clipboard

Copied

Hi,

Up until AIR 14 I was able to prevent the default behavior when pressing ctrl+v in a TextField with Air for Desktop. This allowed me to 'intercept' the pasted text and process it (removing junk markup from MS Word, but retaining some formatting) before adding it into the text field.

Now with AIR 14 calling preventDefault on the KEY_DOWN event on the TextField no longer prevents the paste action. Has anyone else experienced this? Since the TextField doesn't fire a PASTE event I have found no other way to prevent default pasting. I have filed a bug report here:

Bug#3775354 - Unable to prevent default when pasting into TextField with AIR 14

I looked at the change log for AIR 14 and there appears to be a bug fix for ctrl+v/c/x with StageText (which falls back to TextField on desktop). I wonder if this change has something to do with it? This pretty much breaks my entire application so I hope this can get resolved soon!

Thanks.

TOPICS
Performance issues

Views

548

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Jun 13, 2014 0
Adobe Employee ,
Jun 13, 2014

Copy link to clipboard

Copied

Thanks for the heads up.  I've asked someone to take a look at the bug report so expect an update shortly.

Thanks,

Chris

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jun 13, 2014 0
Community Beginner ,
Jun 13, 2014

Copy link to clipboard

Copied

Thanks Chris. I look forward to an update.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jun 13, 2014 0
Adobe Employee ,
Jun 16, 2014

Copy link to clipboard

Copied

The team has been able to reproduce the issue.  Our internal bug number is 3776183.  We'll keep your external bug updated but feel free to reach out to me anytime for updates.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jun 16, 2014 0
New Here ,
Jun 20, 2014

Copy link to clipboard

Copied

I've found an issue that is likely related involving the AdvancedDataGrid.  Overriding keyDownHandler no longer allows capture of CTRL+C, CTRL+V, or CTRL+X.  The workaround posted for bug #3775354 will not work in this case because the listener is added in the constructor in UIComponent.

Adding another key listener with useCapture=true does not intercept the above keystrokes.  I also tried setting priority to 100 and still cannot intercept them.  All other keystrokes I've tested work normally (CTRL+P, ALT+X, SHIFT+1, etc, etc).

Our application relies on these keystrokes to copy/cut/paste data between data grids and to/from Excel.  Our application is in production and being used by hundreds of people for data entry so this is extremely critical for us.  Please restore this behavior ASAP.

Thanks,

Kevin

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jun 20, 2014 0
New Here ,
Jun 23, 2014

Copy link to clipboard

Copied

Hi, Kevin,

Key event will be dispatched from NativeApplication to the UIcomponment in capture phase, and then back to the NativeApplication in bubble phase.

Why the UIComponent won't work is because that the event has been moved from bubble phase to capture stage of the NativeApplication in another bug fixing.

I'd like to know why the listener can't be added like this, you could capture the ctrl+c/v/x/a like this:

NativeApplication.nativeApplication.addEventListener(KeyboardEvent.KEY_DOWN, onPaste,true);

1. The Ctrl+C/V/X/A is the only key combinations Runtime will dealt with inside for copy,paste, select all, and cut.

2. Add the listener to the component always won't be worked on Mac in your ways.

Regards,

Ruiyi

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jun 23, 2014 0
Kevin__K LATEST
New Here ,
Jun 23, 2014

Copy link to clipboard

Copied

Thanks Ruiyl.  Your solution works in my tests and will be tested thoroughly by our QA team.

I would prefer adding the listener in my parent grid class that extends AdvancedDataGrid - we have over 50 separate extensions of this class in our application, so keeping this compartmentalized and not added to NativeApplication would be a cleaner solution.

I worry about developers that aren't actively developing their AIR applications since this bug could break their functionality.  Also, this change adds confusion to the API.  UIComponent.keyDownHandler is what people will override when trying to customize keystrokes for copy/cut/paste/select all.  If this is a permanent change, the API docs should be updated as this will cause a lot of confusion.

Thanks again for your help,

Kevin

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jun 23, 2014 0