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

Re: Faulty Drag Data under QT?


Am 12.02.26 um 14:15 schrieb Claus Dietrich:
Am 12.02.26 um 12:35 schrieb Bruce Steers:

On Thu, 12 Feb 2026, 10:52 Claus Dietrich, <claus.dietrich@xxxxxxxxxx> wrote:

    When I drag a file from Nemo and drop it into my app (gb.gui.qt),
    the
    following 3 lines ....

    Public Sub Form_Drop()
         Print "Drag.Type:"; Drag.Type
         Print Drag.Data
    End

    deliver following strange output in the IDE console:
    Drag.Type: 1
    0:-8:436:20e/claus/Bilder/Bildschirmfoto%20vom%202026-02-08%2016-09-59.png

    When I switch from gb.gui.qt to GTK+3 the IDE console output is
    Drag.Type: 1
    file:///home/claus/Bilder/Bildschirmfoto%20vom%202026-02-08%2016-09-59.png

    Do we have a bug here?
    Best regards
    Claus


No.
Drag.Data is the raw data and it's format can vary depending on toolkit.

You should avoid Drag.Data and use Drag.Paste

Then you should get better results.

Also remember Drag.Type is used mostly only to define between drag.image or some kind of text format.

The format to use for drag.paste (the mime format) will be in either Drag.Format or one of Drag.Formats[]

Drag.Type equaling Drag.Text does not mean you're going to get text/plain mime type.

Respects
BruceS

Thanks! This helped me further, however ...

The property Drag.Formats of dropped file paths from Nemo provides:

index 0:      x-special/gnome-icon-list
index 1:      text/uri-list
index 2:      text/plain
index 3:      text/plain;charset=utf-8

Only when I use

       Print Drag.Paste("text/plain;charset=utf-8")

or

       Print Drag.Paste("text/plain")

I get usable plain file paths, which will do the job and I will go ahead with this in my app.

However, what made me wondering was, that

       Print Drag.Paste("text/uri-list")

provided the same strange output like from the Data-Property. The context help to Drag.Paste says:

"Since 3.18

If _Format_is |"text/uri-list"|, then the method returns a string array of file paths corresponding to the decoded URIs."

This statement seems to be wrong because it returns a single string with all file paths delimited by a LF and the paths returned have the same strange format as provided by the Data property. So either this context help is wrong or this function is buggy.

Do we really have to live with a difference between QT and GTK+3 in this context?


Best regards

Claus

Forget it - finger trouble. I used a faulty Format for Drag.Paste( ). The context help is correct.

Bruce: Your suggestion

  If Drag.Formats.Exist("text/uri-list") Then
    aFiles = Drag.Paste("text/uri-list")
    Print aFiles.Join("\n")
  Endif

is exacly what I needed and works perfectly.

Thanks!

Claus




References:
Faulty Drag Data under QT?Claus Dietrich <claus.dietrich@xxxxxxxxxx>
Re: Faulty Drag Data under QT?Bruce Steers <bsteers4@xxxxxxxxx>
Re: Faulty Drag Data under QT?Claus Dietrich <claus.dietrich@xxxxxxxxxx>