Abe Vionas_MailingList
2004-Oct-05 15:28 UTC
[fxruby-users] Help! Can''t get the FXRuby clipboard example to work...
Essentially, when I select a customers name and click
on the Copy button and then go to notepad and press
CTRL-V (to paste) nothing happens. Anyone have any
ideas?
Here''s my code as it stands...
# customer.rb
require ''fox''
include Fox
customer = Struct.new("Customer", :name, :address,
:zip)
$customers = []
$customers << customer.new("Reed Richards", "123
Maple, Central City, NY", 010111)
$customers << customer.new("Sue Storm", "123 Maple,
Anytown, NC", 12345)
$customers << customer.new("Benjamin J. Grimm", "124
Maple, Anytown, NC", 12345)
$customers << customer.new("Johnny Storm", "123 Maple,
Anytown, NC", 12324)
class ClipMainWindow < FXMainWindow
def initialize(anApp)
# Initialize base class first
super(anApp, "Clipboard Example", nil, nil,
DECOR_ALL, 0, 0, 400, 300)
# Horizontal frame contains buttons
buttons = FXHorizontalFrame.new(self,
LAYOUT_SIDE_BOTTOM|LAYOUT_FILL_X|PACK_UNIFORM_WIDTH)
# Cut and paste buttons
copyButton = FXButton.new(buttons, "Copy")
pasteButton = FXButton.new(buttons, "Paste")
# Place the list in a sunken frame
sunkenFrame = FXVerticalFrame.new(self,
LAYOUT_FILL_X|LAYOUT_FILL_Y|FRAME_SUNKEN|FRAME_THICK,
0, 0, 0, 0, 0, 0, 0, 0)
# Customer list
customerList = FXList.new(sunkenFrame, 6, nil, 0,
LIST_BROWSESELECT|LAYOUT_FILL_X|LAYOUT_FILL_Y)
$customers.each do |customer|
customerList.appendItem(customer.name, nil,
customer)
end
end
def create
super
show(PLACEMENT_SCREEN)
end
end
if __FILE__ == $0
FXApp.new("ClipboardExample", "FXRuby") do |theApp|
ClipMainWindow.new(theApp)
theApp.create
theApp.run
end
end
# User clicks Copy
copyButton.connect(SEL_COMMAND) do
customer customerList.getItemData(customerList.currentItem)
types = [ FXWindow.stringType ]
if acquireClipboard()
@clippedCustomer = customer
end
end
#Handle clipboard request
copyButton.connect(SEL_CLIPBOARD_REQUEST) do
setDNDDATA(FROM_CLIPBOARD, FXWindow.stringType,
Fox.fxencodeStringData(@clippedCustomer.to_s))
end
__________________________________
Do you Yahoo!?
Yahoo! Mail - Helps protect you from nasty viruses.
http://promotions.yahoo.com/new_mail
Kevin Pratt
2004-Oct-05 16:19 UTC
[fxruby-users] Help! Can''t get the FXRuby clipboard example to work...
There were several mistakes in your code I corrected them and below is
the corrected program
Hope this helps. (this may be a dupe for some I also sent this to
ruby-lang as it was asked in both lists)
# customer.rb
require ''fox''
include Fox
customer = Struct.new("Customer", :name, :address,:zip)
$customers = []
$customers << customer.new("Reed Richards", "123
Maple, Central City, NY", 010111)
$customers << customer.new("Sue Storm", "123 Maple,
Anytown, NC", 12345)
$customers << customer.new("Benjamin J. Grimm", "124
Maple, Anytown, NC", 12345)
$customers << customer.new("Johnny Storm", "123 Maple,
Anytown, NC", 12324)
class ClipMainWindow < FXMainWindow
def initialize(anApp)
# Initialize base class first
super(anApp, "Clipboard Example", nil, nil,DECOR_ALL, 0, 0, 400,
300)
#declare member variable clippedCustomer
@clippedCustomer=""
# Horizontal frame contains buttons
buttons = FXHorizontalFrame.new(self,
LAYOUT_SIDE_BOTTOM|LAYOUT_FILL_X|PACK_UNIFORM_WIDTH)
# Cut and paste buttons
copyButton = FXButton.new(buttons, "Copy")
pasteButton = FXButton.new(buttons, "Paste")
# Place the list in a sunken frame
sunkenFrame = FXVerticalFrame.new(self,
LAYOUT_FILL_X|LAYOUT_FILL_Y|FRAME_SUNKEN|FRAME_THICK,
0, 0, 0, 0, 0, 0, 0, 0)
# Customer list
customerList = FXList.new(sunkenFrame, 6, nil, 0,
LIST_BROWSESELECT|LAYOUT_FILL_X|LAYOUT_FILL_Y)
$customers.each do |customer|
customerList.appendItem(customer.name, nil,customer)
end
#Moved this code from the bottome of the file as in needs to be in the
initalization of the window.
#User clicks Copy
copyButton.connect(SEL_COMMAND) do
customer = customerList.getItemData(customerList.currentItem)
types = [ FXWindow.stringType ]
if acquireClipboard(types)
@clippedCustomer = customer
end
end
#moved this code as well.
#Must connect the the _Window_ SEL_CLIPBOARD_REQUREST not the buttons
#Handle clipboard request
self.connect(SEL_CLIPBOARD_REQUEST) do
#setDNDData was misspelled.
setDNDData(FROM_CLIPBOARD, FXWindow.stringType,
Fox.fxencodeStringData(@clippedCustomer.to_s))
end
end
def create
super
show(PLACEMENT_SCREEN)
end
end
if __FILE__ == $0
FXApp.new("ClipboardExample", "FXRuby") do |theApp|
ClipMainWindow.new(theApp)
theApp.create
theApp.run
end
end
Abe Vionas_MailingList wrote:> Essentially, when I select a customers name and click
> on the Copy button and then go to notepad and press
> CTRL-V (to paste) nothing happens. Anyone have any
> ideas?
>
> Here''s my code as it stands...
>
> # customer.rb
>
> require ''fox''
>
> include Fox
>
>
>
> customer = Struct.new("Customer", :name, :address,
> :zip)
>
> $customers = []
> $customers << customer.new("Reed Richards", "123
> Maple, Central City, NY", 010111)
> $customers << customer.new("Sue Storm", "123 Maple,
> Anytown, NC", 12345)
> $customers << customer.new("Benjamin J. Grimm", "124
> Maple, Anytown, NC", 12345)
> $customers << customer.new("Johnny Storm", "123 Maple,
> Anytown, NC", 12324)
>
> class ClipMainWindow < FXMainWindow
> def initialize(anApp)
> # Initialize base class first
> super(anApp, "Clipboard Example", nil, nil,
> DECOR_ALL, 0, 0, 400, 300)
>
> # Horizontal frame contains buttons
> buttons = FXHorizontalFrame.new(self,
> LAYOUT_SIDE_BOTTOM|LAYOUT_FILL_X|PACK_UNIFORM_WIDTH)
>
> # Cut and paste buttons
> copyButton = FXButton.new(buttons, "Copy")
> pasteButton = FXButton.new(buttons, "Paste")
>
> # Place the list in a sunken frame
> sunkenFrame = FXVerticalFrame.new(self,
> LAYOUT_FILL_X|LAYOUT_FILL_Y|FRAME_SUNKEN|FRAME_THICK,
> 0, 0, 0, 0, 0, 0, 0, 0)
>
> # Customer list
> customerList = FXList.new(sunkenFrame, 6, nil, 0,
> LIST_BROWSESELECT|LAYOUT_FILL_X|LAYOUT_FILL_Y)
> $customers.each do |customer|
> customerList.appendItem(customer.name, nil,
> customer)
> end
> end
>
> def create
> super
> show(PLACEMENT_SCREEN)
> end
> end
>
> if __FILE__ == $0
> FXApp.new("ClipboardExample", "FXRuby") do |theApp|
> ClipMainWindow.new(theApp)
> theApp.create
> theApp.run
> end
> end
>
> # User clicks Copy
> copyButton.connect(SEL_COMMAND) do
> customer > customerList.getItemData(customerList.currentItem)
> types = [ FXWindow.stringType ]
> if acquireClipboard()
> @clippedCustomer = customer
> end
> end
>
> #Handle clipboard request
> copyButton.connect(SEL_CLIPBOARD_REQUEST) do
> setDNDDATA(FROM_CLIPBOARD, FXWindow.stringType,
> Fox.fxencodeStringData(@clippedCustomer.to_s))
> end
>
>
>
> __________________________________
> Do you Yahoo!?
> Yahoo! Mail - Helps protect you from nasty viruses.
> http://promotions.yahoo.com/new_mail
> _______________________________________________
> fxruby-users mailing list
> fxruby-users@rubyforge.org
> http://rubyforge.org/mailman/listinfo/fxruby-users
>
>
> .
>
Abraham Vionas_mailinglist
2004-Oct-06 05:11 UTC
[fxruby-users] Help! Can''t get the FXRuby clipboard example towork...
Thanks a bunch Kevin, that did the trick... although it also revealed a bug
in FreeRIDE. HEHEHEhe. I''ll use Mondrian for the next while.
It''s pretty
slick.
-----Original Message-----
From: fxruby-users-bounces@rubyforge.org
[mailto:fxruby-users-bounces@rubyforge.org] On Behalf Of Kevin Pratt
Sent: Tuesday, October 05, 2004 1:19 PM
To: fxruby-users@rubyforge.org
Subject: Re: [fxruby-users] Help! Can''t get the FXRuby clipboard
example
towork...
There were several mistakes in your code I corrected them and below is
the corrected program
Hope this helps. (this may be a dupe for some I also sent this to
ruby-lang as it was asked in both lists)
# customer.rb
require ''fox''
include Fox
customer = Struct.new("Customer", :name, :address,:zip)
$customers = []
$customers << customer.new("Reed Richards", "123
Maple, Central City, NY", 010111)
$customers << customer.new("Sue Storm", "123 Maple,
Anytown, NC", 12345)
$customers << customer.new("Benjamin J. Grimm", "124
Maple, Anytown, NC", 12345)
$customers << customer.new("Johnny Storm", "123 Maple,
Anytown, NC", 12324)
class ClipMainWindow < FXMainWindow
def initialize(anApp)
# Initialize base class first
super(anApp, "Clipboard Example", nil, nil,DECOR_ALL, 0, 0, 400,
300)
#declare member variable clippedCustomer
@clippedCustomer=""
# Horizontal frame contains buttons
buttons = FXHorizontalFrame.new(self,
LAYOUT_SIDE_BOTTOM|LAYOUT_FILL_X|PACK_UNIFORM_WIDTH)
# Cut and paste buttons
copyButton = FXButton.new(buttons, "Copy")
pasteButton = FXButton.new(buttons, "Paste")
# Place the list in a sunken frame
sunkenFrame = FXVerticalFrame.new(self,
LAYOUT_FILL_X|LAYOUT_FILL_Y|FRAME_SUNKEN|FRAME_THICK,
0, 0, 0, 0, 0, 0, 0, 0)
# Customer list
customerList = FXList.new(sunkenFrame, 6, nil, 0,
LIST_BROWSESELECT|LAYOUT_FILL_X|LAYOUT_FILL_Y)
$customers.each do |customer|
customerList.appendItem(customer.name, nil,customer)
end
#Moved this code from the bottome of the file as in needs to be in the
initalization of the window.
#User clicks Copy
copyButton.connect(SEL_COMMAND) do
customer = customerList.getItemData(customerList.currentItem)
types = [ FXWindow.stringType ]
if acquireClipboard(types)
@clippedCustomer = customer
end
end
#moved this code as well.
#Must connect the the _Window_ SEL_CLIPBOARD_REQUREST not the buttons
#Handle clipboard request
self.connect(SEL_CLIPBOARD_REQUEST) do
#setDNDData was misspelled.
setDNDData(FROM_CLIPBOARD, FXWindow.stringType,
Fox.fxencodeStringData(@clippedCustomer.to_s))
end
end
def create
super
show(PLACEMENT_SCREEN)
end
end
if __FILE__ == $0
FXApp.new("ClipboardExample", "FXRuby") do |theApp|
ClipMainWindow.new(theApp)
theApp.create
theApp.run
end
end
Abe Vionas_MailingList wrote:> Essentially, when I select a customers name and click
> on the Copy button and then go to notepad and press
> CTRL-V (to paste) nothing happens. Anyone have any
> ideas?
>
> Here''s my code as it stands...
>
> # customer.rb
>
> require ''fox''
>
> include Fox
>
>
>
> customer = Struct.new("Customer", :name, :address,
> :zip)
>
> $customers = []
> $customers << customer.new("Reed Richards", "123
> Maple, Central City, NY", 010111)
> $customers << customer.new("Sue Storm", "123 Maple,
> Anytown, NC", 12345)
> $customers << customer.new("Benjamin J. Grimm", "124
> Maple, Anytown, NC", 12345)
> $customers << customer.new("Johnny Storm", "123 Maple,
> Anytown, NC", 12324)
>
> class ClipMainWindow < FXMainWindow
> def initialize(anApp)
> # Initialize base class first
> super(anApp, "Clipboard Example", nil, nil,
> DECOR_ALL, 0, 0, 400, 300)
>
> # Horizontal frame contains buttons
> buttons = FXHorizontalFrame.new(self,
> LAYOUT_SIDE_BOTTOM|LAYOUT_FILL_X|PACK_UNIFORM_WIDTH)
>
> # Cut and paste buttons
> copyButton = FXButton.new(buttons, "Copy")
> pasteButton = FXButton.new(buttons, "Paste")
>
> # Place the list in a sunken frame
> sunkenFrame = FXVerticalFrame.new(self,
> LAYOUT_FILL_X|LAYOUT_FILL_Y|FRAME_SUNKEN|FRAME_THICK,
> 0, 0, 0, 0, 0, 0, 0, 0)
>
> # Customer list
> customerList = FXList.new(sunkenFrame, 6, nil, 0,
> LIST_BROWSESELECT|LAYOUT_FILL_X|LAYOUT_FILL_Y)
> $customers.each do |customer|
> customerList.appendItem(customer.name, nil,
> customer)
> end
> end
>
> def create
> super
> show(PLACEMENT_SCREEN)
> end
> end
>
> if __FILE__ == $0
> FXApp.new("ClipboardExample", "FXRuby") do |theApp|
> ClipMainWindow.new(theApp)
> theApp.create
> theApp.run
> end
> end
>
> # User clicks Copy
> copyButton.connect(SEL_COMMAND) do
> customer > customerList.getItemData(customerList.currentItem)
> types = [ FXWindow.stringType ]
> if acquireClipboard()
> @clippedCustomer = customer
> end
> end
>
> #Handle clipboard request
> copyButton.connect(SEL_CLIPBOARD_REQUEST) do
> setDNDDATA(FROM_CLIPBOARD, FXWindow.stringType,
> Fox.fxencodeStringData(@clippedCustomer.to_s))
> end
>
>
>
> __________________________________
> Do you Yahoo!?
> Yahoo! Mail - Helps protect you from nasty viruses.
> http://promotions.yahoo.com/new_mail
> _______________________________________________
> fxruby-users mailing list
> fxruby-users@rubyforge.org
> http://rubyforge.org/mailman/listinfo/fxruby-users
>
>
> .
>
_______________________________________________
fxruby-users mailing list
fxruby-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/fxruby-users