Hello,
I am trying to follow the tutorial for TkDND on the wiki. I am using DND_Text. However, the dropped text is not what was dropped. It seems like it has all the other "control" type information in it as well.
For example, this is the result of a text drop, not at all what I dropped:
Version:0.9
StartHTML:00000147
EndHTML:00000274
StartFragment:00000181
EndFragment:00000238
....
Is there another command/switch that lets you get the plain text instead? Or how do you interpret this result?
On 2/25/2023 4:25 PM, saitology9 wrote:
what os system
what tkdnd version (is that the .9 you output)
what tutorial website
On 2/28/2023 12:45 PM, saitology9 wrote:
On 2/28/2023 12:21 PM, et99 wrote:I tried it from my text editor, and it works correctly.
On 2/25/2023 4:25 PM, saitology9 wrote:
what os system
what tkdnd version (is that the .9 you output)
what tutorial website
Thank you for the feedback.
Quick answers: MS Windows 11, The "0.9" comes from tkdnd itself, and the same tutorial website and the same version of tkdnd as yours.
I dragged some text from my browser. I can only guess that it is because the source is html. I am pretty sure you will see the same thing if you use your browser as the source.
I looked at the output. There is some control stuff like I mentioned, but then comes the html version of the text being dragged; it is there. You just have to extract it I suppose. I was expecting to see plain text as when I do with notepad.
I came across it on the wiki and thought it was interesting. Maybe I will come back to it in the future if I find time.
If you're doing a drag/drop from a webpage, there's
no telling what it will drop. However, I did a d/d from
firefox and also chrome, and I only got the selected text.
So, I'm stumped :)
On 2/28/2023 12:21 PM, et99 wrote:
On 2/25/2023 4:25 PM, saitology9 wrote:
what os system
what tkdnd version (is that the .9 you output)
what tutorial website
Thank you for the feedback.
Quick answers: MS Windows 11, The "0.9" comes from tkdnd itself, and the same tutorial website and the same version of tkdnd as yours.
I dragged some text from my browser. I can only guess that it is because the source is html. I am pretty sure you will see the same thing if you use your browser as the source.
I looked at the output. There is some control stuff like I mentioned, but then comes the html version of the text being dragged; it is there. You just have to extract it I suppose. I was expecting to see plain text as when I do with notepad.
I came across it on the wiki and thought it was interesting. Maybe I will come back to it in the future if I find time.
I tried it from my text editor, and it works correctly.Wait, how did you get that 0.9? If you just type in "package require tkdnd" what do you get?
If you're doing a drag/drop from a webpage, there's
no telling what it will drop. However, I did a d/d from
firefox and also chrome, and I only got the selected text.
So, I'm stumped :)
On 3/1/2023 12:19 AM, et99 wrote:
That is wild! I am stumped too. There is a lot to say on this now :-)I tried it from my text editor, and it works correctly.Wait, how did you get that 0.9? If you just type in "package require tkdnd"
If you're doing a drag/drop from a webpage, there's
no telling what it will drop. However, I did a d/d from
firefox and also chrome, and I only got the selected text.
So, I'm stumped :)
what do you get?
This is close to what I was doing the other day:
package req Tk
package req tkdnd
frame .f
tkdnd::drop_target register .f *
bind .f <<Drop:DND_Text>> {puts "Dropped: \"%D\""; return %A}
bind .f <<Drop:DND_HTML>> {puts "Dropped: \"%D\""; return %A}
bind .f <<Drop:DND_Files>> {puts "Dropped: \"%D\""; return %A}
Now, open your Firefox or Chrome and go to https://wiki.tcl-lang.org/page/TkDND+Tutorial and locate the title that
says "Creating a drop target" and just select/highlight the word "Creating".
Now drop this into the widget above. I get an error message and I
click on "details" button and this is what I see:
First time, I get an error message:
---------------------
extra characters after close-quote
couldn't open "C:/Tcl/Tcl8612/lib/tclIndex": no such file or directory
while executing
"open [file join $dir tclIndex]"
------------------------
After trying again, the message changes to this. I don't recall getting error messages like this but I may be wrong. But you can see that where
it says "Version:0.9, ..."
With firefox:
----------------
extra characters after close-quote
extra characters after close-quote
while executing
"puts "Dropped: {Version:0.9
StartHTML:00000147
EndHTML:00000321
StartFragment:00000181
EndFragment:00000285
SourceURL:chrome://browser/content/br..."
("uplevel" body line 1)
invoked from within
"uplevel \#0 $cmd"
(procedure "::tkdnd::generic::HandleDrop" line 36)
invoked from within
"::tkdnd::generic::HandleDrop $drop_target {} $pressedkeys $rootX $rootY 0" (procedure "::tkdnd::olednd::HandleDrop" line 3)
invoked from within
"::tkdnd::olednd::HandleDrop .f {} 223 240 {HTML Format} {Version:0.9
StartHTML:00000147
EndHTML:00000321
StartFragment:00000181
EndFragment:000002..."
-----------------
With Chrome, you get mixed results. Sometimes it is OK and just prints
out the text you selected. Other times, it gives a similar error message:
----------
extra characters after close-quote
extra characters after close-quote
while executing
"puts "Dropped: {Creating a drop target
A "d"
("uplevel" body line 1)
invoked from within
"uplevel \#0 $cmd"
(procedure "::tkdnd::generic::HandleDrop" line 36)
invoked from within
"::tkdnd::generic::HandleDrop $drop_target {} $pressedkeys $rootX $rootY 0" (procedure "::tkdnd::olednd::HandleDrop" line 3)
invoked from within
"::tkdnd::olednd::HandleDrop .f {} 288 288 CF_UNICODETEXT {Creating a
drop target
A "drop target" is a widget that can accept drops. What we must speci..." ------------------
On 3/1/2023 12:19 AM, et99 wrote:
I tried it from my text editor, and it works correctly.Wait, how did you get that 0.9? If you just type in "package require tkdnd" >> what do you get?
If you're doing a drag/drop from a webpage, there's
no telling what it will drop. However, I did a d/d from
firefox and also chrome, and I only got the selected text.
So, I'm stumped :)
That is wild! I am stumped too. There is a lot to say on this now :-)
This is close to what I was doing the other day:
package req Tk
package req tkdnd
frame .f
tkdnd::drop_target register .f *
bind .f <<Drop:DND_Text>> {puts "Dropped: \"%D\""; return %A}
bind .f <<Drop:DND_HTML>> {puts "Dropped: \"%D\""; return %A}
bind .f <<Drop:DND_Files>> {puts "Dropped: \"%D\""; return %A}
Now, open your Firefox or Chrome and go to https://wiki.tcl-lang.org/page/TkDND+Tutorial and locate the title that says "Creating a drop target" and just select/highlight the word "Creating".
Now drop this into the widget above. I get an error message and I click on "details" button and this is what I see:
First time, I get an error message:
---------------------
extra characters after close-quote
couldn't open "C:/Tcl/Tcl8612/lib/tclIndex": no such file or directory
while executing
"open [file join $dir tclIndex]"
------------------------
After trying again, the message changes to this. I don't recall getting error messages like this but I may be wrong. But you can see that where it says "Version:0.9, ..."
With firefox:
----------------
extra characters after close-quote
extra characters after close-quote
while executing
"puts "Dropped: {Version:0.9
StartHTML:00000147
EndHTML:00000321
StartFragment:00000181
EndFragment:00000285
SourceURL:chrome://browser/content/br..."
("uplevel" body line 1)
invoked from within
"uplevel \#0 $cmd"
(procedure "::tkdnd::generic::HandleDrop" line 36)
invoked from within
"::tkdnd::generic::HandleDrop $drop_target {} $pressedkeys $rootX $rootY 0"
(procedure "::tkdnd::olednd::HandleDrop" line 3)
invoked from within
"::tkdnd::olednd::HandleDrop .f {} 223 240 {HTML Format} {Version:0.9
StartHTML:00000147
EndHTML:00000321
StartFragment:00000181
EndFragment:000002..."
-----------------
With Chrome, you get mixed results. Sometimes it is OK and just prints out the text you selected. Other times, it gives a similar error message:
----------
extra characters after close-quote
extra characters after close-quote
while executing
"puts "Dropped: {Creating a drop target
A "d"
("uplevel" body line 1)
invoked from within
"uplevel \#0 $cmd"
(procedure "::tkdnd::generic::HandleDrop" line 36)
invoked from within
"::tkdnd::generic::HandleDrop $drop_target {} $pressedkeys $rootX $rootY 0"
(procedure "::tkdnd::olednd::HandleDrop" line 3)
invoked from within
"::tkdnd::olednd::HandleDrop .f {} 288 288 CF_UNICODETEXT {Creating a drop target
A "drop target" is a widget that can accept drops. What we must speci..." ------------------
I suspect the substitution where %D is replaced with a string of text containing
quotes, braces, and other special characters
I'm still not sure you are running a recent version. What does a
package require tkdnd
return to you if you type that into a console window? Is it 0.9
where I'm running version 2.x depending on which tcl version I use.
% package require tkdnd
2.2
I also had to add a pack of .f and then add a button .f.b with text
"hello".
to get a drop target.
% pack .f
% button .f.b -text hello
.f.b
% pack .f.b -fill both -expand 1
On 3/1/2023 5:10 PM, et99 wrote:
I'm still not sure you are running a recent version. What does a
package require tkdnd
return to you if you type that into a console window? Is it 0.9
where I'm running version 2.x depending on which tcl version I use.
% package require tkdnd
2.2
It seems more recent than yours:
% package req tkdnd
2.9.2
I also had to add a pack of .f and then add a button .f.b with text "hello". >> to get a drop target.
% pack .f
% button .f.b -text hello
.f.b
% pack .f.b -fill both -expand 1
Sorry - I must not have copied it fully. I had three more lines as follows:
wm geometry . 300x300
pack .f -fill both -expand 1
.f config -bg blue
On 3/1/2023 4:03 PM, Mike Griffiths wrote:
I suspect the substitution where %D is replaced with a string of text containingYes, it definitely looks like it. Its pkgIndex file is also different
quotes, braces, and other special characters
than what you find for other packages in its syntax. I was following its tutorial page on the wiki, so if the examples are causing trouble, it
could be something internal to the package.
I should also emphasize that I was just playing with it. I was not
aware of the package before last weekend, and I suspect my use
(vis-a-vis with a browser as the source) may not have been the intended functionality at all.
Your code prevents error message dialogs. It still generates the same
output I saw originally:
Dropped text: "Version:0.9
StartHTML:00000147
EndHTML:00000321
StartFragment:00000181
EndFragment:00000285
SourceURL:chrome://browser/content/browser.xhtml
<html><body>
<!--StartFragment--><h2 id="3bc024451a44757459cf4c87e16e637b17dd1fb295b2ee51924acd7edaf62743" class="mkup_h1">Creating </h2><!--EndFragment-->
</body>
</html>
| Sysop: | Keyop |
|---|---|
| Location: | Huddersfield, West Yorkshire, UK |
| Users: | 715 |
| Nodes: | 16 (0 / 16) |
| Uptime: | 162:53:29 |
| Calls: | 12,095 |
| Calls today: | 3 |
| Files: | 15,000 |
| Messages: | 6,517,780 |