ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / Developing an application or website / Controls, windows and pages / Controls: Available types / Switch control
  • Overview of the Switch control
  • Creating a Switch control
  • Characteristics of the Switch control
  • "General" tab
  • "Style" tab
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
Overview of the Switch control
Switch controls (also called "Toggle controls") are now commonly used in interfaces.
The Switch control is a 2-state Check Box control (on/off, true/false, yes/no). However, instead of checking a box, the user switches the cursor from right to left (and vice versa) to change the state:
  • the cursor moves when the control is clicked on.
  • the cursor can be moved using the mouse.
On touch screens (smartphones, etc.), the control reacts in a natural way (touch slide).
Examples of Switch controls in both possible positions
Examples of Switch controls in both possible positions
Creating a Switch control
To create a Switch control:
  1. On the "Creation" tab, in the "Usual controls" group, expand "Check Box".
  2. The list of available controls is displayed with the project skin template:
  3. Select the desired Switch control.
  4. Click where the control will be created in the window or page. The control appears in the editor.
To view the characteristics of the control, select "Description" in the context menu.
Characteristics of the Switch control
The description window of the Switch control is used to easily modify its characteristics:
  • The control display mode can be defined in the "General" tab
  • The look of the elements in the Switch control can be customized in the "Style" tab.

"General" tab

The following options are available in the "General" tab:
  • Display mode: : Allows you to define if the captions of the control options will be displayed, and where they will be displayed.
    • presence of a caption:
      • if only one caption is visible: the caption is uncovered depending on whether you switch to the right or left.
      • if both captions are visible: the caption that represents the current state is highlighted through its style (font, color, size, etc.).
    • position of the caption(s):
      • internal: the caption is displayed inside the control, over the background.
      • external: the caption is displayed outside the control (right and/or left).
  • Caption alignment: : Allows you to align the option captions. This option depends on the display mode chosen.
The "General" tab also allows you to enter the caption of the "ON" and "OFF" options and the corresponding value returned to the program. This value will be handled in the WLanguage code. By default, this value corresponds to 0 for the OFF value, and to 1 for the ON value (like a boolean). It is possible to return a value composed of numbers and/or letters. In this case, Value will not return the value as a boolean, but as a text value.
The "Forces the cursor width to take up half of the track" option allows you to use half the width of the control to draw the Switch control when the text is outside. This option is not valid if the captions are inside the control, on the background.

"Style" tab

The "Style" tab allows you to customize the style of the Switch control. You can customize: the ON and/or the OFF value for each control state.
In each case, different elements of the control can be customized: border of the track, border of the cursor, etc.
for more details, see Customizing the Switch controls.
Minimum version required
  • Version 24
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 05/26/2022

Send a report | Local help