[IronPython] Events on Buttons, and Focus, in IronPython
curt at hagenlocher.org
Mon Feb 22 22:12:43 CET 2010
You want args.Key instead of e.Key. The standard event signature is
function(object sender, EventArgs args).
But the better way to do this is to set the OK button to be the default
button. In Winforms, this is a property on the form:
form.AcceptButton = self.ok_button.
On Mon, Feb 22, 2010 at 12:55 PM, Ken MacDonald <drken567 at gmail.com> wrote:
> I've inherited an I-P app, and trying to make some sense of it... It has a
> login page, with several text fields including "user" and "password"; and
> "OK" and "CANCEL" buttons. Right now, you enter the user/password into the
> text fields, and then have to click the "OK" button to login. Customer would
> like this to work like most other apps, where filling in user/password and
> then typing the "Enter" key would also initiate the login. I've searched the
> I-P book and googled, but I can't find a workable reference to how to write
> a handler to determine the Enter key has been hit - actually, I was able to
> catch a keyboard event:
> pwd_fld.KeyDown += on_enter
> def on_enter(self, e, args)
> # what here???
> but unable to determine what the keystroke is - "Iron Python In Action"
> if e.Key == Key.Enter:
> # start login
> but I get the error "e has no attribute 'Key'"
> Clues appreciated....
> Users mailing list
> Users at lists.ironpython.com
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Ironpython-users