Copy to clipboard method


#1

Hi, all,

I’m trying to implement a copy to clipboard functionality, but have been
unsuccessful. The app is mostly ripped from imageviewer.rb
http://www.fxruby.org/doc/examples.html’. Can anyone show me how this
is used. My code to this point is below.

textbox = FXHorizontalFrame.new(splitter,
FRAME_SUNKEN|FRAME_THICK|LAYOUT_FILL_X|LAYOUT_FILL_Y,
:padLeft => 0, :padRight => 0, :padTop => 0, :padBottom => 0)

@textview = FXText.new(textbox, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y)

copyBtn = FXButton.new(toolbar, “Copy\tCopy”, copyicon,
:opts => ICON_ABOVE_TEXT|BUTTON_TOOLBAR|FRAME_RAISED)

def onCmdCopy(sender, sel, ptr)
self.connect(SEL_CLIPBOARD_REQUEST) do
setDNDData(FROM_CLIPBOARD,
FXWindow.stringType,
Fox.fxencodeStringData(@textview.to_s))
end
end

copyBtn.connect(SEL_COMMAND, method(:onCmdCopy))

Thanks,
Kevin