[wxruby-users] lose focus event?
David Morton
mortonda at dgrmm.net
Sat Jan 19 16:27:22 EST 2008
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Jan 19, 2008, at 11:39 AM, Mario Steele wrote:
> Hello David,
>
> First off, welcome to the wxRuby community. Always nice to see new
> faces around, and more interest being sparked in wxRuby, especially
> since it is getting more stable with every release we make. To
> capture Focus Lost, you would need to use evt_kill_focus(), this
> detects when a control looses focus. It's specifically for Windows,
> but since 99.9 percent of the classes we use in wxRuby, are derived
> from wxWindow, you should be able to utilize the evt_kill_focus() to
> detect when a control (Such as a combo box), has lost focus.
>
> Don't think we have a full example of evt_kill_focus() and it's
> counterpart evt_set_focus(), but it's pretty simple, and you can
> find the docs for it here: http://wxruby.rubyforge.org/doc/focusevent.html
>
> If you have any more questions, feel free to ask, we're more then
> happy to help out.
>
Thanks for the generous welcome. I'm usually a unix person, and web
based, but got roped into working on an Access project. (Hence why I'd
rather do this in ruby)
GUI stuff by hand is quite new to me. :)
I see that event firing, but it appears global, firing for everything
that loses focus. I've tried to identify what object was responsible
via #get_event_object, #get_id, and #id, but no luck so far. How do
I associate it with the combo box?
require 'rubygems'
require "wx"
include Wx
class HelloWorld < App
def on_init
helloframe = Frame.new(nil, -1, "Hello World")
button = Button.new(helloframe, :label => 'Close', :pos =>
[200,200])
evt_button(button) {exit}
cbo = ComboBox.new(helloframe,
:pos =>Point.new(10,10),
:choices => ["foo","bar"],
:value => "asdasd",
:style => CB_SORT)
helloframe.show()
evt_set_focus() {|w|
# how do I tie this to cbo ?
}
end
end
HelloWorld.new.main_loop
David Morton
Maia Mailguard http://www.maiamailguard.com
mortonda at dgrmm.net
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (Darwin)
iD8DBQFHkms6Uy30ODPkzl0RAm6nAJ0QM8C4BJpIVduRleF1ci2F45cnsgCguqSU
SD4j0BzY9WsCl+egTkwjxxU=
=qXox
-----END PGP SIGNATURE-----
More information about the wxruby-users
mailing list