When a user interface element (window, control, menu) is created, a special predicate must be defined to handle incoming messages.
The first argument of such a predicate is a message name. Presently
this can be one of the following:
init | sent upon window creation. It is sent before the first paint message. The init message is useful for creation of menus and buttons.
|
paint | the window has to be redrawn. This message is sent every time some part of the window's client area needs to be redrawn. See also paint_rect.
|
close | someone tries to close the window. If the window's function does not process this message or fails while processing
the window will close, otherwise it will not close (sample Sun.spj).
|
size(X, Y) | the window changed its size and the new size of its client
area is X, Y.
|
char(Char, Repetition) | this message is sent when a character is pressed in the window focus
(i.e. when the window is topmost). It has two parameters: Char is
a string with length one which only character is the one pressed. Repetition
is integer which says how many times this char was pressed (if you keep
the button down then Repetition can be bigger than one). If you
want to catch a special key like the arrows then use the message key_down.
|
key_down(CharCode, Repetition) | this message is sent when a key is pressed in the window focus (i.e.
when the window is topmost). It has two parameters: CharCode is an
integer which is equal to the code of the pressed key. Repetition is integer
which says how many times this key was pressed (if you keep the button
down then Repetition can be bigger than one). See also message_flags.
|
key_up(CharCode) | The same as key_down message with the difference that it is sent when the key is released. Also key_up does not have a Repetition parameter.
|
mouse_click(X, Y)
mouse_click_up(X, Y) r_mouse_click(X, Y) r_mouse_click_up(X, Y) |
mouse clicked at coordinates X, Y inside the client area. There are four messages, respectively for left and right mouse button and for down and up click. Here r_ stands for right button and _up stands for releasing the key. See also message_flags.
|
mouse_move(X, Y) | The mouse is moved and the new coordinates are X, Y (in the client area). See also message_flags.
|
mouse_wheel(Delta, X, Y) | The mouse wheel is rotated on Delta steps. This message is sent to the window which has the focus even if the mouse cursor is out of the client area of the window. X and Y are the current coordinates of the mouse cursor (in the screen). Coordinates X, Y are given toward to the upper left corner of the screen. Use the predicate client if you want to transfer screen coordinates to the coordinates in the client area.
See also message_flags.
|
scroll(Direction, Type, Val) | this message is sent to the window when its scroll bar is moved.
The argument Direction is horizontal or vertical. The argument Type is line, page, thumb_track or thumb_moved_to. The argument Val is -1 or 1 if Type is line or page, otherwise it is the new position.
|
scroll(Type, Val, NewPos) | this message is sent to the slider control when it is moved.
The argument Type is line, page, thumb_track or thumb_moved_to. The argument Val is -1 or 1 if Type is line or page, otherwise it is the new position. The argument NewPos always is the new position.
|
press | this message is sent to a button or to menu item when it was pressed.
|
end | send after the end of the timer's period. See also set_timer.
|
edit(Item, Text) | this message is sent to a list box or to a tree box when some one edited
a label in this box. If you want to accept the changes made by the user
then the predicate processing this message should to made this change.
For this purpose it receives the new Text and the Item which is changed.
This message can be send only if you set to the box the style "in place
edit". See also list_box and tree_box.
|
selected(Item) unselected(Item) focused(Item) unfocused(Item) |
these messages are sent to a list box when some item is selected or unselected or
when it receives or loses the focus.
|
Note: if you do not want to process the messages to some given window, a predicate with no clauses for it should be declared as the window's function (e.g. fail(_) ).
Note: after the processing of any message the stack is released in the same way as if the code was ended with: !, fail.
See also:
window
paint_rect
message_flags
client
set_timer
list_box
tree_box
Look at the example:
Fractals.pro (in folder Programs)