Hello,
I ran into a bit of trouble with my first wxRuby application. I’m using
ruby 1.8.6 with wxRuby 1.9.7 on x86 Linux (Ubuntu). Didn’t test any
other platform yet. In my application, I’m trying to access the
clipboard like this:
Wx::Clipboard.open do |clip|
clip.set_data Wx::TextDataObject.new(“TEST”)
clip.flush
end
This doesn’t work. While running the app (after the execution of the
above code), the menu entry “Paste” is enabled in other applications,
but nothing is in the clipboard (at least nothing happens on pasting).
After quitting my application, the menu entry is disabled again and the
clipboard is empty.
How do I access the clip properly?
I still got another question: Is it possible to send key-messages to
other apps using wxWidgets?
Greeting,
Niklas B.
Hi Niklas
Niklas B. wrote:
This doesn’t work. While running the app (after the execution of the
above code), the menu entry “Paste” is enabled in other applications,
but nothing is in the clipboard (at least nothing happens on pasting).
After quitting my application, the menu entry is disabled again and the
clipboard is empty.
How do I access the clip properly?
This code works fine for me on OS X; both while the app is running and
after it’s ended the text data is available to other apps via Paste,
.I’ll try it out on Ubuntu later.
I still got another question: Is it possible to send key-messages to
other apps using wxWidgets?
Not as far as I know, sorry.
alex
Alex F. wrote:
This code works fine for me on OS X;
I tested it on Windows in the meanwhile and it works aswell. But not
under Ubuntu Hardy/GTK
.I’ll try it out on Ubuntu later.
Thanks, that would be very nice!
Greetings,
Niklas
Alex F. wrote:
Niklas B. wrote:
I ran into a bit of trouble with my first wxRuby application. I’m using
ruby 1.8.6 with wxRuby 1.9.7 on x86 Linux (Ubuntu). Didn’t test any
other platform yet. In my application, I’m trying to access the
clipboard like this:
Wx::Clipboard.open do |clip|
Does it help to paste to other applications if you add
clip.use_primary_selection
here? Looking at the wxWidgets drag’n’drop sample, this is needed under
X to share with other applications.
clip.set_data Wx::TextDataObject.new(“TEST”)
clip.flush
end
This doesn’t work. While running the app (after the execution of the
above code), the menu entry “Paste” is enabled in other applications,
but nothing is in the clipboard (at least nothing happens on pasting).
After quitting my application, the menu entry is disabled again and the
clipboard is empty.
It might be worth checking if the data is at least available within your
own application. After doing the set_data, trying retrieving it with
something like
Wx::Clipboard.open do | clip |
data = Wx::TextDataObject.new
clip.get_data(data)
p data.get_text
end
This code works fine for me on OS X; both while the app is running and
after it’s ended the text data is available to other apps via Paste,
.I’ll try it out on Ubuntu later.
I tried it out on Ubuntu and unfortunately I can confirm that neither
within-application or inter-application copying via the Clipboard is
working for me. However I’m using Ubuntu within a VirtualBox VM at the
moment and this has some clipboard integration with the host OS - so I’d
like to this out as the source of the problem.
thanks
alex
Niklas B. wrote:
OK. Thanks for trying anyway.
this doesn’t work either, this prints out my old clipboard content (before running the app).
is there a way i can help finding the source of this problem?
You could try adding Wx::Log.add_trace_mask(‘clipboard’) before the
Clipboard operations. This may give you some more debugging output. But
I tried this already and it all looks in order - the formats are matched
etc. It’s announcing that STRING_UTF8 and STRING data are available
which is correct. Let me know if you see something different.
I spent a few hours trying this under gdb and comparing to the wxWidgets
dnd sample. My hunch is that it’s something to do with the way the C++
classes are mapped onto Ruby. wxWidgets uses a pretty complex structure
of virtual methods in DataObject* that are hard to translate. For
example TextDataObject#get_data_size always seems to report 0 in wxRuby,
which seems wrong.
I’ll keep looking into it
cheers
alex
Hello,
Alex F. [email protected] wrote:
Does it help to paste to other applications if you add
clip.use_primary_selection
here?
unfortunately it does not.
It might be worth checking if the data is at least available within your
own application. After doing the set_data, trying retrieving it with
something like
Wx::Clipboard.open do | clip |
data = Wx::TextDataObject.new
clip.get_data(data)
p data.get_text
end
this doesn’t work either, this prints out my old clipboard content
(before running the app).
is there a way i can help finding the source of this problem?
Greetings,
Niklas