[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Problem with Strings in the Clipboard


On Mon, 19 Jan 2026 at 13:56, Claus Dietrich <claus.dietrich@xxxxxxxxxx>
wrote:

> Am 19.01.26 um 14:27 schrieb Lee:
>
> On 1/19/26 6:05 AM, Claus Dietrich wrote:
>
> According to the documentation clipboard strings containing URLs are not
> returned as the original strings any longer since V3.18.
>
>
> I think you misinterpreted what the documentation says. That note is
> referring to a format of "text/uri-list" which would be a list of URIs not
> a single URL as a string.
>
> The format of "https://www.gambas-buch.de/"; <https://www.gambas-buch.de/>
> is "text/plain" and Clipboard.Paste() works as expected here.
>
> [System]
> Gambas=3.21.1
> Platform=x11
> Desktop=KDE
> [Libraries]
> QT6=libQt6Core.so.6.10.1
>
> Try the attached mini demo. Copy the URL of the upper TextArea via the
> context menu and paste it through the button into the below TextArea, were
> you should find something very different than the URL.
>
> As Bruce said, it depends on the source. The documentation doesn't seem to
> cover the complexity of this subject and I have to admit that I still don't
> have the full picture.
>
> Best regards
>
> Claus
>

I think this is less about Clipboard and more about why does TextArea copy
plain text as html ?
For some reason selecting "copy" on the TextArea text copies the plain text
as a whole html page.

Clipboard.Paste() is working as expected.
But Clipboard.Format is "text/html" not "text/plain"

With your demo program this also works...
Public Sub Button1_Click()

  If Clipboard.Format = "text/html" Then
     TextArea2.Text = FromHtml(Clipboard.Paste())
  Endif

End

When checking Clipboard.Formats i noted it has text/html and text/markdown
(it also has plain/text but most files have plain/text)

"If Clipboard.Type = Clipboard.Text" does not mean it is text/plain it
mostly just means it is not Clipboard.Image.

You got the right idea by using text/plain you force that type.
(actually probably a better solution to my way of inspecting the formats :)

Ps. From experience I'd say be careful using Clipboard.Format to check for
a particular type.
Favour using "If Clipboard.Formats.Exist(sFormat)" because it may "have"
the format you want but Clipboard.Format might not be that one.

Respects
BruceS

References:
Problem with Strings in the ClipboardClaus Dietrich <claus.dietrich@xxxxxxxxxx>
Re: Problem with Strings in the ClipboardLee <t.lee.davidson@xxxxxxxxx>
Re: Problem with Strings in the ClipboardClaus Dietrich <claus.dietrich@xxxxxxxxxx>