Map the Enter key to a Tab

Posted by vancejohnson2 on 21-Jul-2008 12:36

Does anyone know how to map the Enter key to a Tab in a CLS file at the form level or on any control?

All Replies

Posted by Peter Judge on 22-Jul-2008 14:05

Does anyone know how to map the Enter key to a Tab in

a CLS file at the form level or on any control?

You can set your Form's KeyPreview property to True (this means the form handles all key events from its contained controls), and then override the KeyPress (or KeyUp or KeyDown) event, check for the Enter key, then call your Form's ProcessTabKey method to perform the Tab. You'll also need to set e:Handled = True to prevent the Enter key being processed too.

There are also some caveats with this approach, which are listed here (its also where I got the above info): http://www.duncanmackenzie.net/blog/517/default.aspx. Note that this uses VB.NET code but it explains the issues nicely

You might also be able to use a similar approach for your F12 question. (KeyPreview = True; OnKey looks for F12).

-- peter

Posted by vancejohnson2 on 24-Jul-2008 14:09

This works pretty well in a simple form, but when I try it in my form, pressing Enter always sends me to the first tab stop. Try this: Create a new ABL MIDI Form, set the KeyPreview property of the form to True in Events, press Enter in the KeyDown field, paste in your code in the newly created method, save it, return to the designer, select the toolbar, click the little arrow on the right, select Embed in ToolStripContainer, select Dock Fill In Form, add 3 ultra text editors in the Control Panel area of toolStripContainer1, save it, and run it. Tabbing around works just fine, but if you go to any field and press Enter and you'll see that it always returns to the first editor. I tried setting the tab stops 0-4 and I still get the same behavior. It seems the ToolStripContainer is misbehaving.

Posted by Admin on 06-Oct-2009 23:35

There are also some caveats with this approach, which are listed here (its also where I got the above info): http://www.duncanmackenzie.net/blog/517/default.aspx. Note that this uses VB.NET code but it explains the issues nicely


Hi Peter,

that link does not work anymore. Do you have some more information about those issues (an archived version of that blog)?

Mike

Posted by Peter Judge on 07-Oct-2009 09:00

mikefe wrote:

There are also some caveats with this approach, which are listed here (its also where I got the above info): http://www.duncanmackenzie.net/blog/517/default.aspx. Note that this uses VB.NET code but it explains the issues nicely


Hi Peter,

that link does not work anymore. Do you have some more information about those issues (an archived version of that blog)?

Mike

I think this is it:  http://www.duncanmackenzie.net/Blog/Enter-Instead-of-Tab

-- peter

Posted by Thomas Mercer-Hursh on 07-Oct-2009 12:02

Before you do this, I would suggest stepping back and asking yourself seriously whether you really want to do this.  I expect that the reason you are asking is because you have user used to ChUI screens, where ENTER was commonly used to move between fields (although TAB worked) and now they are encountering GUI screens where expected behavior is different.  But, consider that every other Windows application uses TAB to move between fields.  Isn't there some value in being consistent with established standards?  And, what then do you do about places where ENTER has meaning ... like selecting an entry in a combo-box, for example?  Yes, you may have some confusion for a few days, but it will soon be over and you will be way ahead if you don't do this.

Posted by Admin on 07-Oct-2009 22:32

Thomas, I'm really surprised that you are participating in a GUI usability thread

First of all the success of every new application is based on user acceptance. Using the ENTER key in a way that's closer to what worked in the legacy application, let it be Progress CHUI or the traditional GUI is big step to user acceptance.

Secondly, the defacto standard for usability and appearance on the Windows Desktop is the Microsoft Office.

Do me a favor:

- Install Microsoft Outlook 2007

- Create a new contact

- Make sure the focus is in the first (name) field

- Hit the Enter key

This thread is closed