|
|
|
|
|
- Method 1: Using WLanguage events associated with the control
- Method 2: Using the Event function
How to color a control with focus?
The caret is not always easy to identify in a window: sometimes, we may not not even know the control where the input is performed. How to highlight the control where the input is performed? Two methods are available: Method 1: Using WLanguage events associated with the control - In the entry code of control, change the background color and/or the color of characters with BackgroundColor and Color.
- In the exit code of the control, use the default style color for the background color and/or color of characters with BackgroundColor and Color with the DefaultColor constant.
Example: // -- Entry in the control MySelf.BackgroundColor = DarkBlue MySelf.Color = White
// Loss of focus MySelf.BackgroundColor = DefaultColor MySelf.Color = DefaultColor
Drawback: This operation must be performed "manually" on each control. This method is convenient if a small number of controls must be modified. Method 2: Using the Event function Event is used to intercept the Taking Focus and Losing Focus events in the project or in each window to process. Each one of the events must be associated with a WLanguage procedure in order to change the color or to restore the initial color. Example: - Code to enter in the "Initializing" event of the project:
Event(ProcColor, "*.*", 7) // 7 = WM_SETFOCUS Event(ProcUncolor, "*.*", 8) // 8 = WM_KILLFOCUS
- Global WLanguage procedure called by the Event function (gain of focus):
PROCEDURE ProcColor {_EVE.name, indControl}..BackgroundColor = DarkBlue {_EVE.name, indControl}..Color = White
- Global WLanguage procedure called by the Event function (loss of focus):
PROCEDURE ProcUncolor {_EVE.name, indControl}..BackgroundColor = DefaultColor {_EVE.name, indControl}..Color = DefaultColor
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|