[fxruby-users] changing FXTextField default behavior

angico angico at angico.org
Tue Aug 26 04:21:47 EDT 2008


Hi,

Is it possible to change the data from an event, SEL_KEYPRESS or
SEL_KEYRELEASE or the like, in order to, say, randomly change the codes
of each keystroke?

If it is, how could I achieve this?

I've tried this:

text = FXTextField.new(self, 20)
text.connect(SEL_KEYPRESS, method(:changeText))
...
def changeText(sender, selector, data)
	A = 'A'.sum 0
	Z = 'Z'.sum 0
	a = 'a'.sum 0
	z = 'z'.sum 0

	c = data.code

	case c
	when A .. Z
		c = rand(25) + A
	when a .. z
		c = rand(25) + a
	end

	if c != data.code
		data.code = c
	end

	false
end

But it doesn't work, and if I type in "hello", that's exactly what I see
in the control.

So, again, is it possible to change that data?

Thank you,

-- 
angico
------
home page: www.angico.org
Gnu/Linux, FLOSS, Espiritismo, e eu por mim mesmo 8^I
------
contatos:
email: angico at angico.org
skype: angico00
------



More information about the fxruby-users mailing list