Javascript OnPaste

The onpaste event fires before the input‘s value is changed. You need something such as a setTimeout: <input type=”text” placeholder=”Paste text” onPaste=”var e=this; setTimeout(function(){alert(e.value);}, 4);”>​ I’m storing a reference to this inside a global var as this is not accessible inside the scope of a timeout function which is attached to the window object. I’m … Read more

Get text from clipboard using GetText – avoid error on empty clipboard

Handle the errors with On Error GoTo as shown here: Sub GetClipBoardText() Dim DataObj As MSForms.DataObject Set DataObj = New MsForms.DataObject ‘<~~ Amended as per jp’s suggestion On Error GoTo Whoa ‘~~> Get data from the clipboard. DataObj.GetFromClipboard ‘~~> Get clipboard contents myString = DataObj.GetText(1) MsgBox myString Exit Sub Whoa: If Err <> 0 Then … Read more

jQuery bind to Paste Event, how to get the content of the paste

There is an onpaste event that works in modern day browsers. You can access the pasted data using the getData function on the clipboardData object. $(“#textareaid”).bind(“paste”, function(e){ // access the clipboard using the api var pastedData = e.originalEvent.clipboardData.getData(‘text’); alert(pastedData); } ); Note that bind and unbind are deprecated as of jQuery 3. The preferred call … Read more

Android copy/paste from clipboard manager

you can copy and paste text using following code : for copy : ClipboardManager clipboard = (ClipboardManager)getSystemService(Context.CLIPBOARD_SERVICE); ClipData clip = ClipData.newPlainText(“your_text_to_be_copied”); clipboard.setPrimaryClip(clip); And paste it : ClipboardManager clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE); String pasteData = “”; // If it does contain data, decide if you can handle the data. if (!(clipboard.hasPrimaryClip())) { } else if (!(clipboard.getPrimaryClipDescription().hasMimeType(MIMETYPE_TEXT_PLAIN))) … Read more

Enable copy and paste on UITextField without making it editable

My final solution was the following: I created a subclass of UILabel (UITextField should work the same) that displays a UIMenuController after being tapped. CopyableLabel.m looks like this: @implementation CopyableLabel – (BOOL)canPerformAction:(SEL)action withSender:(id)sender { if(action == @selector(copy:)) { return YES; } else { return [super canPerformAction:action withSender:sender]; } } – (BOOL)canBecomeFirstResponder { return YES; } … Read more

Excel VBA How to detect if something was pasted in a Worksheet

Private Sub Worksheet_Change(ByVal Target As Range) Dim UndoList As String ‘~~> Get the undo List to capture the last action performed by user UndoList = Application.CommandBars(“Standard”).Controls(“&Undo”).List(1) ‘~~> Check if the last action was not a paste nor an autofill If Left(UndoList, 5) = “Paste” Then ‘Do stuff End If End Sub This did the trick. … Read more