Re: [Fxruby-users] FXTreeList as DND source
Status: Inactive
Brought to you by:
lyle
|
From: Lyle J. <jl...@cf...> - 2003-10-03 21:23:02
|
Dalibor Sramek wrote:
> May I have one more wish? Could you put down a short example of accessing
> either clipboard or the primary selection from a widget that does not have
> this capability by default.
> When I had no success with the DND I tried to put the data from FXTreeList
> to the clipboard. I looked at the FXText.cpp file for inspiration. However
> it seemed to me that FXTreeList could not acquire neither clipboard nor
> primary selection.
> I believe the mechanism is very similar to DND. Am I right?
Yes, the mechanism is very similar to DnD, but obviously a little
simpler. Attached is an example of how you might copy something from a
tree list to the clip board, although as you will see, the fact that the
clipboard owner is an FXTreeList doesn't have all that much bearing on
the problem. The key steps are:
1. Deciding on some mechanism that the user will use to copy
some application data to the clipboard. By convention, you'll
probably want to use the Ctrl+C keypress, plus maybe some other
options like a "Copy" menu command or a toolbar. But that's
really an orthogonal issue.
2. First you need to acquire ownership of the clipboard by
calling acquireClipboard() on some window. As with beginDrag(),
you use this opportunity to "advertise" what data format(s)
(a.k.a. drag types) they can request from you.
3. The clipboard owner sends a SEL_CLIPBOARD_GAINED message to
its message target to indicate that yes, you acquired the
clipboard. I don't *think* there's any way for this to fail, so
it's probably just a formality. But there you go.
4. The important message is SEL_CLIPBOARD_REQUEST. Like the
SEL_DND_REQUEST message, this tells you that someone is requesting
the data and you should cough it up by calling setDNDData().
Note that in this case, the first argument to setDNDData() is
FROM_CLIPBOARD instead of FROM_DRAGNDROP.
5. Finally, if (when) some other window claims the clipboard,
you'll get a SEL_CLIPBOARD_LOST message.
The attached example is short and sweet, but hopefully it demonstrates
the important parts.
Hope this helps,
Lyle
|