I followed the instructions in the manual, but despite I have picture AND text in my clipboard, I only can retrieve the text from the clipboard. I need to copy the picture alone to the clipboard to grab it from the clipboard.
There must be a way when picture AND text are on the clipboard, that you can grab them simultaneously from the clipboard. Somehow the code in the manual does not see the picture.
How are you copying both at the same time?
I select them from a html page. When I paste it in Word, then picture and text are paste.That tells me they are both in the clipboard. But .pictureavailable does not see it when there is also text.
May need to use something like:
s = clip.RawData("public.html")
This is from a test using the above and showing into a HTMLViewer:
Gotcha.
What is probably happening is that when you copy, the web browser is placing two versions of the data onto the clipboard: the text-only version which you are successfully reading, and a more complex data type like HTML or RTF that you arenât aware of. Youâll need to figure out which one it is and devise a way to read it in your app; thereâs no way to control how the web browser handles it.
I tried to find out what data is on the clipboard:
Blockquote
Var c As Clipboard
Var clipPic As Picture
c = New Clipboard
If c.RawDataAvailable(âpublic.rtfâ) Then
TextArea1.StyledText.RTFData = c.RawData(âpublic.rtfâ)
End If
if c.RawDataAvailable(âpublic.htmlâ) then
TextArea1.StyledText.RTFData = c.RawData(âpublic.htmlâ)
end if
If c.PictureAvailable Then
clipPic = c.Picture
Canvas1.Backdrop = clipPic
End If
Var clipText As String
If c.TextAvailable Then
TextArea1.text = c.Text
End If
c.RawData(âpublic.rtfâ) = TextArea1.StyledText.RTFData
c.Close
Blockquote
But I have the feeling something is missing
It skips the first three if statements (so it is not true) and goes to c.textavailable and print the text in the textarea.
The picture is also on th eclipboard, but it is not seen.
Word can paste HTML.
Xojoâs text area (as far as I know) can not render HTML to it.
So, even when Word shows your HTML picture the TextArea will not show it. If you paste the HTML copy/paste to a Xojo HTMLviewer you will see something very similar to Word, as I showed on my screenshot above.
No problems here. iâm using a Mac. Is hard to see the highlight over the Break (this is Xojo 2024r4.1 maybe the highlight is better on a newer version)
It skips the first three if statements and find a match with the last one, while there is a picture too ono the clipboard:
Ah, you no longer have HTML but a Picture, right?
In other words, you no longer select a picture/text from a browser?
You really need to get/install âClipboard Viewerâ, that will give you more information on what the OS is saving to the clipboard and you will be able to figure how to pull that information into Xojo.
Testing Xojo options will not give you the results you need.
For example, copying an image into the mac Clipboard, Clipboard Viewer shows this information:
so you will need code like:
if c.RawDataAvailable("public.tiff") then
break
end if
Hope this helps.
Using Windows-11 you can press windowskey+v to see the history of your clipboard. However, it does not show anything clear.
I installed a clipboard viewer and there I saw when I select and copy a whole page (picture and text) it only copies the text to the clipboard. When I explicitly select the picture and copy it as image, then the picture is copied to the clipboard.
So, it looks I have to do the load in two steps. No problem, it speeds up what I want anyway.
Thanks for your responses, it did help.
You forget the basic rule: you can Paste only what the target application know !
In Short: you can paste texts to TextArea, but not Pictures
you can paste Pictures to Canvas, but not Texts.
For the code, read entries above.
PS: you can in your own application Place a Text and an Image in the Clipboard (or so it as possible long time ago), you can even Paste to your application both at the same time: you are the developer and can code that. (Send Clipboard.Text to a TextArea.Text, Image to a Canvas.Backdrop for example).
I see you already have code to Paste bothâŠ
I did do thatâŠchecked on text, is it there copy it to textarea. Checked on pictureâŠnot found. While I copied a page containing picture and text on to clipboard.
When I paste it in Word both are found.
If I only copy the picture, it is found and copied to canvas. Somehow it cannot find both on clipboard.
Share a simple project⊠that loads an image, place it in the Clipnoard and load a Text and place it in the Clipboard.
Then Map the Paste to a TextArea (Text) and a Canvas.Backdrop (Image); that is what basically you are asking.
(and forget abour Word).
The program I have, I am not asking for it. I simply want to copy and picture and text in one turn from the clipboard.
With .pictureAvailable and .textAvailable this should be manageble. However, when I have both on the clipboard only .textAvailable is true. The picture is not seen.
When I copy the image into clipboard it is seen by .pictureAvailable.
My question is: is there a way to find as well the picture as the text on the clipboard in one turn. When not possible I do it in 2 turns.
I already shared the code above.
Did you install and use the specific Clipboard Viewer app that was suggested? Thatâs going to be the first step towards making this happen.
If so, what is your conclusion ?
I wrote the esample (the simple way as I show the design above) and this does not works.
The only way I can think is to use RawData:
place the text in a MemoryBlock,
Place the Picture aftet the Text in the same MemoryBlock,
Pass the MemoryBlock as RawData in the Clipboard on Copy, and decrypt the MemoryBlock at Paste time.
Or any other way to combine Text and Data, then place the result in the Clipboard and reverse the things at Paste time.
Saying this differently:
do it in two times
OR
do not use the Clipboard to Paste the data, but determine the Clipboard contents (using the adviced software) and send directly (no Paste) the data where they belong.
FYI: Gimp clears the Clipboard contents when you quit the application (even if the Clipboard was filled elsewhereâŠ)
Yes
And what âflavorâ of data does it say is on the clipboard?