Author Topic: Mastering InForm: Buttons with Focus  (Read 15674 times)

0 Members and 1 Guest are viewing this topic.

Offline Qwerkey

  • Forum Resident
  • Posts: 755
Mastering InForm: Buttons with Focus
« on: September 05, 2018, 04:28:39 pm »
I have just discovered that a Button which has received focus reacts to a Carriage Return by executing the code which is placed under that Button's __UI_Click section.  This is without any written code in the __UI_KeyPress section (and there looking for __UI_KeyHit = 13).  This was a great surprise to me, as I was just about to create some code in the __UI_KeyPress section for this very purpose.

Is this supposed to happen?

Is this a well-known property for "Windows (& others) -like" Forms?  If so, it must have occurred in Visual Basic 6 which I have completely forgotten.

Richard

FellippeHeitor

  • Guest
Re: Mastering InForm: Buttons with Focus
« Reply #1 on: September 05, 2018, 04:44:59 pm »
I have just discovered that a Button which has received focus reacts to a Carriage Return by executing the code which is placed under that Button's __UI_Click section.  This is without any written code in the __UI_KeyPress section (and there looking for __UI_KeyHit = 13).  This was a great surprise to me, as I was just about to create some code in the __UI_KeyPress section for this very purpose.

Is this supposed to happen?

Is this a well-known property for "Windows (& others) -like" Forms?  If so, it must have occurred in Visual Basic 6 which I have completely forgotten.

Richard


It is supposed to happen. You can also activate a focused button with the space bar, as it's standard behavior across Windows versions.

If you create a button with a caption-hotkey (by adding an ampersand character before the &Desired letter) you can also activate it with Alt+Letter at run time.

Also: set a button as default (by right-clicking it->"Set as default" at design time) and it'll also respond to Enter even if the button doesn't have focus (say your user is editing a text field and hits enter).
« Last Edit: September 05, 2018, 04:46:53 pm by FellippeHeitor »

Offline Qwerkey

  • Forum Resident
  • Posts: 755
Re: Mastering InForm: Buttons with Focus
« Reply #2 on: September 06, 2018, 04:21:27 am »
I knew about the HotKey action, but completely forgot the CR.