QB64.org Forum

QB64 Team Software => InForm Discussion => Topic started by: Qwerkey on September 05, 2018, 04:28:39 pm

Title: Mastering InForm: Buttons with Focus
Post by: Qwerkey 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
Title: Re: Mastering InForm: Buttons with Focus
Post by: FellippeHeitor 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).
Title: Re: Mastering InForm: Buttons with Focus
Post by: Qwerkey on September 06, 2018, 04:21:27 am
I knew about the HotKey action, but completely forgot the CR.