[fxruby-users] FXTextField

Uwe Hartl uwe.hartl at gmx.net
Sun Jan 29 03:19:29 EST 2006


Hi Joel,

this seems to work, too. Thank you.

Now I thought I found the wisdom with the message forwarding, but this is far 
from complete, I guess. I try now to make the FXText to ignore some keys. 
There are two FXText showing the same information, therefore I used a 
FXDataTarget. To make the FXText to ignore the keys and I inherited the 
FXText. In the subclass I connect to the SEL_KEYPRESS and filter the input. 
This procedure works great with one FXText, but it does not transfer the Info 
to the other FXText via the DataTarget. Here ist the test - code:  


require 'fox14'
include Fox

class UHS_FXText < FXText
	def initialize(p, tgt=nil, sel=0, opts=0, x=0, y=0, w=0, h=0, pl=3, pr=3, 
pt=2, pb=2)
		super
		setValidChars("1234567890 :z")
	end
	def setValidChars(validchars)
		connect(SEL_KEYPRESS) {|sender, sel, item|
			ret = true
			if validchars.include?(item.text)
				ret = false
			else
				puts "Key not handled!"
			end
			ret
		}
	end
end

class Welcome < FXMainWindow
	def initialize()
		super($theApp, 'Welcome to the Manager', icon=nil, miniIcon=nil, 
opts=DECOR_ALL, x=0, y=0, width=300, height=300)
		tgt = FXDataTarget.new("FOX")
		fr = FXVerticalFrame.new(self, LAYOUT_FILL_X|LAYOUT_FILL_Y)
		dt1 = UHS_FXText.new(fr, tgt, FXDataTarget::ID_VALUE, opts= LAYOUT_FILL_X|
VSCROLLING_OFF|HSCROLLER_ALWAYS)
		dt1.visibleRows = 2
		dt2 = UHS_FXText.new(fr, tgt, FXDataTarget::ID_VALUE, opts= LAYOUT_FILL_X|
VSCROLLING_OFF|HSCROLLER_ALWAYS)
		dt2.visibleRows = 2
	end
end

if $0 == __FILE__
	$theApp = FXApp.new
	$wn = Welcome.new
	$wn.show
	$theApp.create
	$theApp.run
	p "finishing up"
end

May be, you can figure this out...

Thanks
Uwe


More information about the fxruby-users mailing list