Any way to make MUI button react to Enter key?

3 posts / 0 new
Last post
ChrisH's picture
Last seen: 3 years 10 months ago
Joined: 2010-12-07 20:22
Any way to make MUI button react to Enter key?

In MUI is there any simple way I can make an "OK" button react to the Enter key, while still having Enter work with a string gadget as expected? For example, so I can make a MUI equivalent for C:RequestString.

I see that MUIA_Window_InputEvent allows reacting to IDCMP_RAWKEY, but (a) I imagine that Enter will still generate a RawKey event when the string gadget is active, and (b) I have no idea what a "standard commodities.library input description string" is (the unhelpful example is "-repeat f1").

tboeckel's picture
Last seen: 4 years 1 day ago
Joined: 2011-09-13 12:32
The "standard

The "standard commodities.library input description string" are the strings you are using for example for the CX_HOTKEY definitions of commodities. They simply describe the input event to cause a certain action. "-repeat f1" simply means pressing the F1 key but without repeated pressed caused by a non-released key. "lshift ctrl f10" would react on F10 being pressed while only the left SHIFT key and the CTRL key are pressed. Quite simple and easy to understand.

But ENTER and RETURN are a bit special in MUI's context. Although it is possible and valid to set up input event notificiations for these keys your application will most probably never see these key pressed as they are catched and swallowed by MUI already unless you redefine the PRESS key event on the Keyboard page of MUI prefs. Thus in general this is a bad idea because even if you adjusted your settings accordingly you would force everybody else to do the same which clearly contraticts the MUI design rules. Furthermore the standard action of ENTER/RETURN is first passed to the active object (indicated by a second colored frame) then to the the default object (to be set by the application) and finally (if nobody else has eaten the event) to all other objects.

If you want a single button to react on ENTER/RETURN then just make it the active object. That's all. The button will get the active object's second colored frame and immediately react on ENTER/RETURN key presses. This technique is used in MUI requesters to make it easier to close the requester with a standard "answer" (i.e. Ok).

thomas's picture
Last seen: 5 hours 17 min ago
Joined: 2011-05-16 14:23
Why not just use set

Why not just use set (ok_button,MUIA_ControlChar,'\r') ?


Log in or register to post comments