Hi
I have a following small program in which I am enabling or disabling a
button depending on the presence of text in the text filed. I am using
the FXDataTarget connected to the text field. I also want to add
possibility to paste the data into text filed upon pressing right
mouse button etc. Now, everything works fine until I try to connect
the mouse button action to the text field, then the FXDataTarget stops
working. I am attaching the program; the mouse staff is commented out.
Please have a look test the program with un- and commented lines.
#----------
require "rubygems"
require "fox16"
include Fox
class MyProject < FXMainWindow
def initialize (app, title)
super(app,title, :opts=>DECOR_ALL^(DECOR_SHRINKABLE|
DECOR_STRETCHABLE|DECOR_RESIZE)|
LAYOUT_EXPLICIT,:width=>400,:height=>300)
@female_target = FXDataTarget.new("")
female_text = FXTextField.new(self, 25,:target =>
@female_target, :selector => FXDataTarget::ID_VALUE, :opts =>
TEXTFIELD_NORMAL|TEXTFIELD_ENTER_ONLY|
LAYOUT_EXPLICIT,:x=>85, :y=>12,:width=>120, :height=>25)
#female_text.connect(SEL_RIGHTBUTTONRELEASE) do |sender, sel,
event|
# end
@female_target.connect(SEL_CHANGED) do |sender, sel, data|
if data.size>0 and @number_target.value.size>0
@submit_button.enable
else
@submit_button.disable
end
end
@number_target = FXDataTarget.new("")
number_text = FXTextField.new(self, 25,:target =>
@number_target, :selector => FXDataTarget::ID_VALUE, :opts =>
FRAME_NORMAL|TEXTFIELD_ENTER_ONLY|
LAYOUT_EXPLICIT,:x=>85, :y=>47,:width=>90, :height=>25)
@number_target.connect(SEL_CHANGED) do |sender, sel, data|
if data.size >0 and @female_target.value.size>0
@submit_button.enable
else
@submit_button.disable
end
end
@submit_button=FXButton.new
(self,"Submit",:x=>85, :y=>180, :width=>300, :height=>24,:opts=>LAYOUT_EXPLICIT|
BUTTON_NORMAL)
@submit_button.connect(SEL_COMMAND) do
end
@submit_button.disable
end
def create
super
show(PLACEMENT_SCREEN)
end
end
app = FXApp.new
MyProject.new(app, "test")
app.create
app.run
#---------
Thanks
Krzys
_______________________________________________
fxruby-users mailing list
fxruby-users@...
http://rubyforge.org/mailman/listinfo/fxruby-users