Any way to make MUI button react to Enter key?

4 posts / 0 new
Last post
ChrisH's picture
Last seen: 3 years 3 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: 3 years 5 months 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 days 18 hours ago
Joined: 2011-05-16 14:23
Why not just use set

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


Stark544's picture
Last seen: 2 weeks 3 days ago
Joined: 2023-10-16 13:04
Re: Any way to make MUI button react to Enter key?

I'm thrilled to share that implementing the Enter key functionality for MUI buttons has greatly enhanced user experience on my website. Now, users can effortlessly engage with the interface by simply hitting Enter, streamlining navigation. This enhancement not only adds convenience but also aligns seamlessly with the overall user-friendly design. For more insights into optimizing user engagement, I highly recommend checking out the insightful content at site. It's a valuable resource that delves into effective strategies for creating an intuitive and responsive user interface. Cheers to the developers for continually improving accessibility and ensuring a smooth user journey!

Log in or register to post comments