Is used to change, through programming, the theme (dark or light) used by the mobile application.
// When modifying the Check Box control "CBOX_NightMode"
IF CBOX_NightMode THEN
// Initialize project theme using system theme
ChangeTheme(<Theme> [, <Option>])
<Theme>: Integer constant
Theme to apply:
|stThemeAutomatic||Default theme used by the mobile device. The theme changes automatically according to the system settings. |
|stThemeDark||Forces the use of the dark theme. |
|stThemeLight||Forces the use of the light theme. |
<Option>: Optional Integer constant
Indicates whether theme change events should be run:
|All WLanguage events related to the theme application are run in the following order: |
- Event "Application of light/dark theme" of the project.
- Optional event "Application of light/dark theme" of the windows.
- Optional event "Application of light/dark theme" of the internal windows.
Remark: If the dark theme cannot be applied to the window (option "Do not apply dark theme" in the "Style" tab of the window description), the event "Application of light/dark theme" is not run in this window, but it is run in all the other open windows and in the project.
|withoutCodeExecution||No WLanguage event (project and/or windows or internal windows) linked to the application of the light/dark theme is run. |
The dark theme must have been enabled in the application in order to use ChangeTheme:
- Open the project description window: on the "Project" tab, in the "Project" group, click "Description".
- In the "Style" tab, check "Allow switching to dark theme (automatically or manually via ChangeTheme)".
If the dark theme has not been allowed, ChangeTheme
returns an error.
Operation and special cases
- The automatic mode is used by default.
- If the selected theme corresponds to the current theme, ChangeTheme has no effect.
- When ChangeTheme is used, the theme is changed in all the windows of the application (except in those for which the option "Do not apply dark theme" is checked in the "Style" tab of the description window.
- Windows opened next will use the theme specified with ChangeTheme.
Business / UI classification: UI Code