ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / WLanguage / WLanguage functions / Controls, pages and windows / Control functions
  • Focus gain
  • ScreenFirst, SetFocus and SetFocusAndReturnToUserInput
  • Error
  • SetFocusAndReturnToUserInput on a window
  • SetFocusAndReturnToUserInput on a Table control column
  • SetFocusAndReturnToUserInput on the current control
  • SetFocusAndReturnToUserInput on the last selected control
  • Events/processes executed when SetFocusAndReturnToUserInput is called
  • SetFocusAndReturnToUserInput and END:
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Others
Stored procedures
Stops the current process, sets the focus to the specified control, window or page, and allows the user to enter data.
WEBDEV - Browser code SetFocusAndReturnToUserInput can be used in a browser event (onchange, onclick, etc.), but it cannot be used in a local procedure or a global browser procedure.
Remark: This function is equivalent to ReturnToCapture.
Example
// If no value was entered by the user in the control
IF EDT_Edit1 = "" THEN
// Display a message and position the user in edit on the control
Error("Enter a value")
SetFocusAndReturnToUserInput(EDT_Edit1)
END
WINDEVReports and QueriesJavaUser code (UMC)
// Position the mouse cursor in a cell of a Table control (multi-selection or not)
TABLE_Table_Name = Row_Index
SetFocusAndReturnToUserInput(TABLE_Table_Name.COL_Column_Name)
Syntax
SetFocusAndReturnToUserInput([<Element to handle>])
<Element to handle>: Optional control, window or page name
Name of control, column or window that will gain focus (see Notes). If this parameter is not specified, the current control gains focus.
To specify a control that belongs to a window other than the current window, <Element to handle> must be in the following format: <Window name>.<Control name>.
WEBDEV - Browser code Name of the control or page that will gain focus (see Notes). If this parameter is not specified, the last current control gains focus.
Android Name of the control or window that will gain focus (see Notes). If this parameter is not specified, the current control gains focus.
Remarks

Focus gain

Taking "focus" is represented in different ways:
  • Blinking cursor (or "Caret") for the edit controls.
  • Dotted rectangle for the other types of controls (Button, List Box, Radio Button controls, etc.).

ScreenFirst, SetFocus and SetFocusAndReturnToUserInput

These functions have a different behavior:
  • SetFocusAndReturnToUserInput stops the current process to force the input in the specified control.
  • ScreenFirst defines which control will receive input focus (when the current code stops and input focus is set back to a control).
  • SetFocus stops the current process, defines which control will receive input focus and resumes the current process.

Error

A WLanguage error occurs if <Element to handle> does not correspond to a control in the current window or page.
WINDEVReports and QueriesAndroidJavaUser code (UMC)

SetFocusAndReturnToUserInput on a window

If <Element to handle> corresponds to the name of a window, the window becomes active. The control that will gain focus in this window will correspond to:
  • the last control previously in edit in this window,
  • the first control that can gain focus in this window (if no data was previously entered).
WINDEVReports and QueriesJavaUser code (UMC)

SetFocusAndReturnToUserInput on a Table control column

SetFocusAndReturnToUserInput sets the focus on the specified column. If the Table control is not receiving any input, it becomes editable.
WINDEVReports and QueriesAndroidJavaUser code (UMC)

SetFocusAndReturnToUserInput on the current control

SetFocusAndReturnToUserInput used without parameters sets the focus on the current control. This function, called in the exit code of an Edit control, is used to force the input in the selected control if the data entered and the expected data do not match.
WEBDEV - Browser codeAjax

SetFocusAndReturnToUserInput on the last selected control

SetFocusAndReturnToUserInput used without parameters sets the focus on the current control. This function, called in the exit code of an Edit control, is used to force the input in the selected control if the data entered and the expected data do not match.
The control must be one of the following types of controls:
  • Edit control.
  • Check Box control.
  • Radio Button control.
  • List Box control.
  • Combo Box control.
  • "Clickable area" Image control.
If the name of the control corresponds to a string that is built, the alias of the control must be used ("ControlAlias"+Num for example). In this case, no check is performed: JavaScript errors may occur if focus is given to a control that does not exist.
Reminder: The alias of a control corresponds to the name of this control in the HTML page. To find out this alias:
  • in the code editor, press Shift + F1.
  • through programming, use the Alias property.
WINDEVReports and QueriesAndroidJavaUser code (UMC)

Events/processes executed when SetFocusAndReturnToUserInput is called

The WLanguage code that follows the call to SetFocusAndReturnToUserInput is not executed and control is given to the user.
Special cases:
  • if SetFocusAndReturnToUserInput is called in a code called by Execute, ExecuteCode or ExecuteProcess, the code called by Execute, ExecuteCode or ExecuteProcess is interrupted. The execution resumes after the call to Execute, ExecuteCode or ExecuteProcess.
  • if SetFocusAndReturnToUserInput is called in the code of a function of a window other than the current one, the code of this function is interrupted and execution resumes after the call.
  • if SetFocusAndReturnToUserInput is called in the code of a component (procedure or method), the code is interrupted and execution resumes after the call to the procedure or method.
  • if SetFocusAndReturnToUserInput is called in the code of a procedure of an internal window, the code is interrupted and execution resumes after the call to the procedure.
  • if SetFocusAndReturnToUserInput is called in the code of a menu option, the code is interrupted and execution resumes after the call to the option.
  • if SetFocusAndReturnToUserInput is called in a window procedure called from a supercontrol, the code is interrupted and execution resumes after the call to the procedure.
  • if SetFocusAndReturnToUserInput is called in the code of a procedure of a supercontrol or control template, the code is interrupted and execution resumes after the call to the procedure.
The current process is permanently interrupted. For example:
SetFocusAndReturnToUserInput(EDT_Edit1)
Info("XXX")    // Is never run
In most cases, the exist events (from the current control or window) and the input events (in the specified control or window) are run at the same time as SetFocusAndReturnToUserInput.
Exceptions:
  • No code is executed if <Element to handle> is the current control.
  • The exit code of the selected control is not run if SetFocusAndReturnToUserInput is used in one of the events of this control.
To avoid interrupting the process, use ScreenFirst or SetFocus.
AndroidJava The WLanguage code that follows the call to SetFocusAndReturnToUserInput is not executed. The execution of processes resumes:
WINDEVReports and QueriesAndroidJavaUser code (UMC)

SetFocusAndReturnToUserInput and END:

After a call to SetFocusAndReturnToUserInput, the code that follows the "END:" statement is not executed. SetFocusAndReturnToUserInput can be replaced with the call to ScreenFirst followed by RETURN.
Business / UI classification: UI Code
Component: wd300obj.dll
Minimum version required
  • Version 27
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 05/31/2022

Send a report | Local help