Button command execution

Is there a way to set up buttons in an interface so that pressing 'enter' can activate it, like in other Windows interfaces? It seems like there should be a way since I can 'tab' through MEL created controls, but I can't figure out how to execute button presses. Thanks.

The window is activated when you click on it... but yes that would be possible. Just map your enter into something beyond the default.

The situation I'm trying to make easier is when a window has controls that take several different inputs (ints, floats, or strings, or checkboxes or whatever). Obviously clicking an 'apply' button will activate it, but I'd like to not have to grab the mouse to apply those values, but just press enter. I also know that if I only have one control in a UI that I could just set it to execute every time the value changes, but most of the time I have several controls. I could definitely map the enter key to do this if I could figure out which UI control in the window is currently 'active'. There doesn't seem to be a way to query this in the window or button commands, but I could be missing something.

To trap the Enter Key press, you could try playing around with the commandLine MEL command.

As for knowing which control currently has the focus, there doesn't seem to be a way to do this directly. A control can do any number of routines in its -changeCommand section. Each time a control is modified, one of the things you could do is set a global variable with the name of the control. In theory, that variable would have the name of the last modified control when the enter button is pressed.

g-