Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > tk question - how do i bind to multiple events?

Reply
Thread Tools

tk question - how do i bind to multiple events?

 
 
Max Williams
Guest
Posts: n/a
 
      10-18-2007
I have a text field, and i want to get the value out of it when the user
presses Return or tabs to another field. Currently i'm doing it like
this:

name_field = TkEntry.new(root)
var = TkVariable.new("f")
name_field.textvariable(name_var)
name_field.pack()

name_field.bind("Key-Return") { name_field_value = name_var.value }
name_field.bind("FocusOut") { name_field_value = name_var.value }

It seems like there should be a way to combine these, like

name_field.bind("Key-Return" || "FocusOut") #doesn't work
name_field.bind("Key-Return", "FocusOut") #doesn't work either

But these doesn't work. Can anyone tell me how to do this please?
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
 
 
 
Hidetoshi NAGAI
Guest
Posts: n/a
 
      10-18-2007
From: Max Williams <(E-Mail Removed)>
Subject: tk question - how do i bind to multiple events?
Date: Thu, 18 Oct 2007 21:15:10 +0900
Message-ID: <(E-Mail Removed)>
> name_field.bind("Key-Return") { name_field_value = name_var.value }
> name_field.bind("FocusOut") { name_field_value = name_var.value }
>
> It seems like there should be a way to combine these, like
>
> name_field.bind("Key-Return" || "FocusOut") #doesn't work
> name_field.bind("Key-Return", "FocusOut") #doesn't work either
>
> But these doesn't work. Can anyone tell me how to do this please?


Please use TkVirtualEvent object.
-------------------------------------------------------------------------
virt_ev = TkVirtualEvent.new("Key-Return", "FocusOut")
# or use TkVirtualEvent#add(seq, ...) / TkVirtualEvent#delete(seq, ...)

name_field.bind(virt_ev) { name_field_value = name_var.value }
-------------------------------------------------------------------------
--
Hidetoshi NAGAI ((E-Mail Removed))

 
Reply With Quote
 
 
 
 
Max Williams
Guest
Posts: n/a
 
      10-18-2007
Hidetoshi NAGAI wrote:

> Please use TkVirtualEvent object.
> -------------------------------------------------------------------------
> virt_ev = TkVirtualEvent.new("Key-Return", "FocusOut")
> # or use TkVirtualEvent#add(seq, ...) / TkVirtualEvent#delete(seq, ...)
>
> name_field.bind(virt_ev) { name_field_value = name_var.value }


Great, thanks!
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
confused by boost::bind & boost::lambda::bind XHengDF@gmail.com C++ 0 05-29-2007 04:37 AM
bind multiple data tables from sql queries to multiple datacontainers? Daves ASP .Net 1 01-06-2006 04:17 PM
Using a data-bind dropdownlist to populate another data-bind dropdownlist mr2_93 ASP .Net 1 10-02-2005 05:07 PM
Bind multiple selections to a query John Hoge ASP .Net 2 11-30-2004 10:12 PM



Advertisments