I know its ICCCM compliant. As tcl man pages rightly put it
the details were confusing at first sight. But, even after
understanding the contents of ICCCM, my question is:
Can Tcl/Tk really be used to exchange info in other than
plain STRING format???
In other words:
Say from my editor, if I have to copy "formatted text(proprietary)" to
clipboard and
let other applications just paste only the plain string
my editor should paste the formmatted text
what should I do??
What should I do, If I need to paste an Bitmap image copied from
PaintBrush on Windows.
How do I implement "Paste Special" functionality of Windows
applications
in my Tcl/Tk based editor??? In other words, can a client get the
details
of Clipboard owner, the formats the data can be converted to by the
owner.
Any clarifications, pointers to references would be greatly appreciated.
Regards,
nagu.
It is possible, using options to the selection and clipboard commands
(specifically, the -type option). See the clipboard and selection
man pages, paying close attention to the use of type.
** Jeffrey Hobbs jeff.hobbs @SPAM acm.org **
** I'm really just a Tcl-bot My opinions are MY opinions **
Thanks for your response.
I did read the selection man pages. I still could not
figure out how I could, say for example, retrieve the
image that I copied using PaintBrush on Windows
into my editor code.
I tried the following:
- Start PaintBrush(or any other app) and copy
something to clipboard
- Run wish
- Executed the following:
for {set i 1} {i < 100} {incr i} {
selection get -selection CLIPBOARD \
-type [winfo atomname $i]
}
none of the atoms really returned me anything. But I tried the
samething
with a string(text) copied to the clipboard I did get the copied string
when atomname was STRING.
So, am I still missing something???!!!!!
Regards,
nagu.
Hmm, it was possible to get a STRING from Paint, but not a
picture. Perhaps the type is not correct just by grabbing
all the atomname types? I would think so, but the following
description of the ICCCM mechanism is very confusing:
http://www.tronche.com/gui/x/icccm/sec-2.html
I know that you can create special handlers that will work
within Tk. Perhaps this mechanism is also not 100% integrated
for Windows??
- the owner of the CLIPBOARD
- Formats into which the owner can present the clipboard data
If a requestor can decide and enumerate these details on demand,
then a requesting software can give a sophisticated user interface
to paste the data. An example: Windows' Paste Special operation.
I guess the MULTIPLE atom is something to do with this. But,
wish gives the result: MULTIPLE undefined.
A special handler is for owners who wants to handle the
presentation of data to requesting clients.
If Tcl/Tk has to be a successful "Portable" platform, then
Selection mechanism has to be really really portable. What
an easy way to do Inter Process Communication with native
applications!!!!
Hoping to get more specific details ....
regards,
nagu.
Results on Windows:
First of all, the atoms are not unique
across the applications. MYOWN_TEXT_TYPE
gets different id on different apps.
selection exchanges using atoms work
only within the same application.
It does not even work across Tk
applications.
Interpretation:
I guess, its more of a bug in the implementation
selections on Windows platform.
Further Question:
How do I enumerate the different types of data
that are copied to the clipboard????
Code Example:
## Set Selection Type
set selection CLIPBOARD
## Create ATOMs
set x [winfo atom MYOWN_TEXT_FORMAT]
set y [winfo atom MYOWN_TEXT_TYPE]
## Create TextWidget to display debug info
text .tw
pack .tw
.tw insert insert "\nx = $x, y = $y\n"
## Set the selection handlers
## My own Type and My own Format
selection handle \
-selection $selection \
-type MYOWN_TEXT_TYPE \
-format MYOWN_TEXT_FORMAT \
. {handleMyOwnMyOwn}
## String Type String Format
selection handle \
-selection $selection \
-type STRING \
. {handleMyOwn}
## Handler1
proc handleMyOwnMyOwn {offset maxBytes} {
.tw insert insert \
"\nhandleMyOwnMyOwn Invoked...\n"
return "\nMYOWN_TEXT_TYPE MYOWN_TEXT_FORMAT\n"
}
## Handler2
proc handleMyOwn {offset maxBytes} {
.tw insert insert \
"\nhandleMyOwn Invoked...\n"
return "\nMYOWN_TYPE STRING\n"
}
## Own the selection
selection clear -selection $selection
selection own -selection $selection .
## Invoke the selection
## Check the debug info displayed on text widget
.tw insert insert [selection get \
-selection $selection \
-type MYOWN_TEXT_TYPE]
.tw insert insert [selection get \
-selection $selection]
## end
Regards,
nagu.
"Donal K. Fellows" wrote:
>
> Yes, on X (I use the facility in my own applications to transfer
> hierarchical object descriptions about. These don't really make too
> much sense as ordinary strings - I suppose they work, but they are
> unpleasant to use - so I give them a different type atom.) Maybe not
> on other platforms though, due to differences in exactly what is meant
> by a non-STRING format.
>
> Selections, clipboards, and their associated platform differences.
> Very very deep stuff. We probably need a Wiki article on the topic...
>
> Donal.
> --
> Donal K. Fellows http://www.cs.man.ac.uk/~fellowsd/ fell...@cs.man.ac.uk
> -- The small advantage of not having California being part of my country would
> be overweighed by having California as a heavily-armed rabid weasel on our
> borders. -- David Parsons <o r c @ p e l l . p o r t l a n d . o r . u s>