clipboard

Strangeness with clipboard access

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-30 14:11:45
I'm trying to write a small application that needs to use the clipboard for some functionality. Since I don't want to overwrite the user's data currently in the clipboard I decided to save it to memory, do my job and then write it back. The code below is a console application that is a barebones example of what I'm trying to do. The problem I'm having is restoring the state. If I copy something to the clipboard from Visual Studio before running the application there are a total of six objects in the clipboard (various string formats and a locale) which all get put in the cache. Once I restore

Copy current URL to clipboard

丶灬走出姿态 提交于 2019-11-30 13:59:56
Not sure why this has been so difficult for me today, but for some reason I cannot seem to get it to copy the current URL to the clipboard. Overall, I'm looking for a way to do it without needing to create some hidden text elements. This is what I'm trying so far: var shareBtn = document.querySelector(".share-button"); shareBtn.addEventListener('click', function(event) { var cpLink = window.location.href; cpLink.select(); try { var successful = document.execCommand('copy'); var msg = successful ? 'successful' : 'unsuccessful'; console.log('Copy command was ' + msg); } catch (err) { console.log

Copy-Paste image in Android using Clipboard Manager

有些话、适合烂在心里 提交于 2019-11-30 13:17:21
问题 I would like to copy image from my android application to the other android application using clipboard manager. I have researched a lot and read this tutorial but it doesn't cover the image copying part. The below code which copies image but when I am trying to paste, only the image's path is pasted. ContentValues values = new ContentValues(2); values.put(MediaStore.Images.Media.MIME_TYPE, "image/png"); values.put(MediaStore.Images.Media.DATA, "/mnt/sdcard/1.jpg"); ContentResolver theContent

Android Text Selection In Webview

。_饼干妹妹 提交于 2019-11-30 12:58:30
问题 I am using webview for displaying content in Android Honeycomb(3.x). I created customized action menu for cut,copy and paste.How can i copy the selected text in Webview by using my customized action menu. 回答1: May It Will Help... public void selectAndCopyText() { try { Method m = WebView.class.getMethod("emulateShiftHeld", null); m.invoke(this, null); } catch (Exception e) { e.printStackTrace(); // fallback KeyEvent shiftPressEvent = new KeyEvent(0,0, KeyEvent.ACTION_DOWN,KeyEvent.KEYCODE

Selected Rows in QTableView, copy to QClipboard

心已入冬 提交于 2019-11-30 12:04:38
问题 I have a SQLite-Database and I did it into a QSqlTableModel . To show the Database, I put that Model into a QTableView . Now I want to create a Method where the selected Rows (or the whole Line) will be copied into the QClipboard . After that I want to insert it into my OpenOffice.Calc-Document. But I have no Idea what to do with the Selected SIGNAL and the QModelIndex and how to put this into the Clipboard. 回答1: To actually capture the selection you use the item view's selection model to get

Why show java.lang.ClassCastException: android.text.SpannableString cannot be cast to java.lang.String?

不想你离开。 提交于 2019-11-30 11:48:29
When copying String from any browser page, pasteData works properly. However when copying SpannedString from a message sent item editor(field), the application crashes and shows this error message: java.lang.ClassCastException: android.text.SpannableString cannot be cast to java.lang.String My code: // since the clipboard contains plain text. ClipData.Item item = clipBoard.getPrimaryClip().getItemAt(0); // Gets the clipboard as text. String pasteData = new String(); pasteData = (String) item.getText(); where the ClipboardManager instance defined as clipBoard , below: clipBoard =

Making a JEditorPane with html put correctly formatted text in clipboard

老子叫甜甜 提交于 2019-11-30 11:32:24
I have this code to demonstrate the problem: public static void main(String[] args) { JFrame frame = new JFrame(); frame.getContentPane().add(new JEditorPane("text/html", "Hello cruel world<br>\n<font color=red>Goodbye cruel world</font><br>\n<br>\nHello again<br>\n")); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.pack(); frame.setLocationRelativeTo(null); frame.setVisible(true); } If you select all the text that appears in the frame once the app starts, you can copy it and paste it into MS Word, Apple's Pages, or Mail and the text is formatted correctly. But if you paste it

Clipboard change notification?

 ̄綄美尐妖づ 提交于 2019-11-30 10:49:35
问题 I know how put content to and retrieve content from the clipboard. However, between these two operations, it is possible for another operation to change the content of the clipboard. Is there a way to be notified when any application modifies the clipboard? 回答1: All I could find was a Clipboard Monitor written in C#/VB.NET. I see WPF and WinForms, so I assume this is a viable options. Involves pinvoking some methods from the user32 dll. EDIT At the time of edit, the original link above is

Copying and pasting image into a textbook in simulator

蓝咒 提交于 2019-11-30 10:28:09
I'm manually setting the copied content in the pasteboard @IBAction func onOkPressed( button: UIButton ) { var testImage = getImageWithColor(UIColor.redColor(), size: CGSize(width: 100, height: 100)); UIPasteboard.generalPasteboard().image = testImage } func getImageWithColor(color: UIColor, size: CGSize) -> UIImage { UIGraphicsBeginImageContextWithOptions(size, false, 0) color.setFill() UIRectFill(CGRectMake(0, 0, 100, 100)) var image = UIGraphicsGetImageFromCurrentImageContext() UIGraphicsEndImageContext() return image } But when I paste the image into a textbox in simulator it doest not

C# Clipboard.GetText()

孤人 提交于 2019-11-30 08:18:44
How can I get the clipboard text in a non static thread? I have a solution but I'm trying to get the cleanest/shortest way possible. The results turn up as an empty string when calling it normally. I would add a helper method that can run an Action as an STA Thread within a MTA Main Thread. I think that is probably the cleanest way to achive it. class Program { [MTAThread] static void Main(string[] args) { RunAsSTAThread( () => { Clipboard.SetText("Hallo"); Console.WriteLine(Clipboard.GetText()); }); } /// <summary> /// Start an Action within an STA Thread /// </summary> /// <param name=