View Full Version : Accessing ClipBoard Text
17 Aug 2011, 8:20 AM
Does anybody know how to access clipboard text in Ext JS.?
Do we have onpaste event for textfield component??
17 Aug 2011, 11:12 AM
Thus far in my travels I've not seen code that will copy to the clipboard in Ext (I've yet to find code that will do it cross-browser at all, honestly. All I've personally been able to get working is IE). So, perhaps another community member can guide you (and by extension me) to a solution.
I believe the closest thing you'll find to an onpaste event is the change event. In Ext 2/3 I used to watch for keyup events and that would fall apart when you paste using the mouse / context menu. So, I'd set up a repeating task to monitor the field - not a great use of resources, really, but that's what I did. Now with Ext 4 you can just listen to the change event and that will trigger whenever the field value is changed no matter the execution.
17 Aug 2011, 2:28 PM
It's certainly useful, but considered to be a security risk, and so browsers other than IE won't give you access to it. With IE, you use "window.clipboardData.getData()" or "window.clipboardData.getText()" to get the text.
HTML5 is supposed to provide clipboard events, and the clipboard data is passed within the events, but there's little to no implementation of this available.
One sleazy way to get around this is with a Flash hack (http://code.google.com/p/zeroclipboard/)
Sorry there aren't better answers out there!
Powered by vBulletin® Version 4.2.3 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.