Window events and functions¶
Event function¶
event = func_id
The name of the function to be called when an event occurs in this window.
The function is called as follows:
func_id(event_code, window_id)
Certain events send additional arguments.
The events which cause the function to be called are:
EV_CREATE |
The window has been created. |
||||||||||
EV_DESTROY |
The window has been destroyed. |
||||||||||
EV_GAIN_FOCUS |
The window has gained focus. |
||||||||||
EV_LOSE_FOCUS |
The window has lost focus. |
||||||||||
EV_MINIMISED |
The window has been minimised. |
||||||||||
EV_MAXIMISED |
The window has been maximised. |
||||||||||
EV_RESTORE |
The window has been restored from a maximised size to its default size. |
||||||||||
The user has moved the mouse over the window during a dialog. |
|||||||||||
The user has clicked down or released the right mouse button within the window or the program’s system tray icon (but not over a control). Note that this event is not a default event and must be enabled, e.g.
See the event_enable clause. A common use for EV_RIGHT_MOUSE_UP is to open a popup menu.The event sends extra arguments to the event function indicating the position of the click:
|
|||||||||||
EV_CHANGE |
The user has resized the window. The event sends extra arguments to the event function:
The new width and height can be retrieved from the view_width and view_height properties, e.g.
The event_detail argument describes the resize event in more detail. Possible values for event_detail are:
Note that EV_CHANGE is not a default event and must be enabled:.
|
||||||||||
EV_CLOSE |
The user has clicked on the window’s close icon. It is the programmer’s responsibility to accept the request, and then to close or destroy the window, as appropriate for the application, or to refuse the request. Unless the window has the style flag WS_HOTWINDOW assigned, EV_CLOSE is only generated during a dialog. If the user clicks a window’s close button while a textbox has focus and the EV_CLOSE event function causes the program to exit, then by default any value typed into the textbox is not saved. This allows a program to be closed even though invalid data has been typed into the textbox. If the program requires the value to be saved, subject to validation, the event function can execute the save_text command. |
||||||||||
EV_SELECT_TAB |
This event is generated when a tab in a tab control window is selected. Note that the event function must be assigned to the tab control window; it need not be assigned to the tab control child windows. EV_GAIN_FOCUS is not used because it is the tab control window that receives focus, not the tab itself. See Tab control windows. This event sends extra arguments to the event function:
|
||||||||||
EV_SYSTEM_TRAY_ICON |
This event is generated by mouse clicks on the program’s system tray icon. The system_tray_icon() function is used to create and manage the system tray icon. The event is tested in combination with the mouse click event, in order to distinguish from the same mouse event in the window. The following events can be tested with EV_SYSTEM_TRAY_ICON:
|
||||||||||
EV_DRAG_ENTER
EV_DRAG_LEAVE
EV_DRAG_OVER
EV_DROP
|
These drag and drop events can only be generated for a window with the style flag WS_DROP_TARGET. See Using drag and drop. If drag and drop events are required, they must be enabled in the target window by means of the event_enable clause. Enabling EV_DRAG_DROP enables all drag and drop events. The following example enables drag and drop in addition to those events enabled for a window by default:
|
New events may be added in the future. See Event functions.
Event enable function¶
event_enable = flags
This clause is used to select the event codes which are to be enabled for the window.
Default: The standard set of events listed under the event = clause above.
RELATED TOPICS