Events of graphics objects
Graphics object events are actions which can trigger the execution of scripts when performed.
The following events are available as standard:
Events | Action | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Acknowledge | When acknowledged | ||||||||||||||||||||
Activated | When the user presses the Return or Enter key or double-clicks a date in the calendar widget. | ||||||||||||||||||||
AreaClosed |
The event is triggered when closing an area inside of the trend.
Please note that the passed |
||||||||||||||||||||
Change | Change of slider position. | ||||||||||||||||||||
Changed | When an item of a selection list is selected. | ||||||||||||||||||||
Clicked |
Left-click. For primitive shapes the event can also be triggered by
other available buttons. The exception is the right click, which has
its own event. The button being used is specified in the mapping
Note:
If the MousePressed event
is also defined, this is triggered first. Note:
To use the middle mouse button to activate
scripts, panning must be deactivated with [ui] middleMousePanning. This event is only triggered if the mouse button is released on the object on which the click event has been started. |
||||||||||||||||||||
Command | A text field event. It is executed when you press the Enter key. | ||||||||||||||||||||
CurrentPageChanged | When the currently shown month or year is changed in the calendar widget. The new year and month are passed as parameters. | ||||||||||||||||||||
CursorPositionChanged | Is started when the cursor position in a textEdit document changes. | ||||||||||||||||||||
CurveDataError | This script is triggered from each DPE, when receiving an error,
while using dpGetPeriod , from the Data-Manager using
(Available for: Trend widget). |
||||||||||||||||||||
CurvesScaled |
This event will be activated after a timeout of 500ms and supplies in
a |
||||||||||||||||||||
DoubleClicked |
Left-double-click. Note:
Note that if the
MousePressed/MouseReleased
event is also defined, this is triggered first. If no |
||||||||||||||||||||
DragDrop | This event will be started when the user drops the information onto
it and the shape notified the system before to accept the dropped media
with dropAccept() . For more information, see chapter
Drag & drop at runtime. |
||||||||||||||||||||
DragEnter | This event will only be started when the shape accepts drops (the acceptDrops attribute in the attribute editor has been set) and has not been disabled. The shape must decide if it is prepared to accept the dropped information. For more information, see chapter Drag & drop at runtime. | ||||||||||||||||||||
DragStart |
This event will only be started when the "Draggable" attribute of the attribute editor has been set to "TRUE". For more information, see chapter Drag & drop at runtime. CAUTION:
Note that you can drag the
cells of a table to an object (for example, a
textWidget) by default. If you, however,
modify the dragStart event, add a code and then
delete the code but not the entire script including
main{} , you cannot drag the cells anymore. Bear
in mind that you have to delete the entire script. |
||||||||||||||||||||
GestureTriggered | The event is triggered when you swipe an embedded module (refer to Properties and events of the panel for a detailed description on this event). | ||||||||||||||||||||
HeaderClicked | Executes an event if a header of a table is clicked with the left mouse button. | ||||||||||||||||||||
Initialize | When opened
Note:
The order in which objects are initialized within the context cannot be determined! |
||||||||||||||||||||
KeyboardFocusIn | When focus is set on an object | ||||||||||||||||||||
KeyboardFocusOut | When focus of an object is lost | ||||||||||||||||||||
LangChanged | When the language is changed. | ||||||||||||||||||||
ModificationChanged |
This event will be started when the modification status of a
textEdit document has changed. If
|
||||||||||||||||||||
MouseOver |
The mouse is moved over an object. Note:
Note that the MouseOver
event contains the boolean parameter enter which is
TRUE when the mouse is moved over the object and FALSE when the
mouse leaves the object. This allows you to, for example, set
different background colors depending on the position of the
mouse. |
||||||||||||||||||||
MousePressed |
Left mouse button pressed. For primitive shapes the event can also be
triggered by other available buttons. The exception is the right
click, which has its own event. The button being used is specified
in the mapping Note:
To use the middle mouse button to activate
scripts, panning must be deactivated with [ui] middleMousePanning. This means that the script is started whenever the mouse button is pressed. Whether it will be released afterwards is irrelevant. If the mouse cursor with pressed mouse button is moved outside of the button border (or a simple graphics object), the event is triggered each time the mouse cursor moves to the object. |
||||||||||||||||||||
MouseReleased |
Left mouse button released. For primitive shapes the event can also
be triggered by other available buttons. The exception is the right
click, which has its own event. The button being used is specified
in the mapping Note:
To use the middle mouse button to activate
scripts, panning must be deactivated with [ui] middleMousePanning. The script is started whenever the mouse button moves up. This can be either when the mouse button is released or when the mouse cursor is moved away from the button (or simple graphics object). The event is triggered again after re-entering and again leaving the area of an object. |
||||||||||||||||||||
OnButtonDblClk | Left-double-click on a DPTree. | ||||||||||||||||||||
|
In contrast, |
||||||||||||||||||||
OnLButtonClk | Left-click on a DpTreeView. | ||||||||||||||||||||
Resized | Is executed when the object's size has been changed. | ||||||||||||||||||||
ReturnPressed | Is executed when the Return key is pressed in a textEdit document. | ||||||||||||||||||||
RightMousePressed | Right-click | ||||||||||||||||||||
Scrolled | To be able to only query and display data you can currently see and
to avoid extensive queries that could take a long time, a
scrolled event has been implemented. Thus, data
will be requested for an area of a table widget when you scroll to that
area and not before. The scrolled event is executed 0.3
seconds after you stop scrolling the table.
Note:
Note that the table must be filled with rows. |
||||||||||||||||||||
SelectionChanged |
When changing the tab or whenever the "selected" state of a primitive shape changes, either interactively by the user selecting the shape or by the CTRL programmer setting the "selected" attribute programmatically. See Multiselection at run time. Or whenever the selected lines of a table are changed, for example,
via keyboard MultiSelections. Note that you have to use the
following functions when using the event
|
||||||||||||||||||||
Slide | When you slide the Slider. | ||||||||||||||||||||
TabCloseRequested | Only available for the tab widget. The event is activated when closing a tab is attempted. | ||||||||||||||||||||
TextChanged |
This event type only exists for the graphic objects TextEdit and Text field. The event is called whenever the user types something or text is changed via Control code. To access the new text inside the event the event parameter
|
||||||||||||||||||||
Wheel |
The The
|
Event Trigger
-
Events that are triggered when the panel is opened during initialization (
Initialize
). If the script has been defined for panel properties and not for graphic objects, thenInitialize
will not be executed. -
Click events that are triggered by user actions (clicking with the mouse).
-
Events that are triggered when the slider position is changed (
Change
). -
Events that are triggered by the focus position (
KeyboardFocusIn
,KeyboardFocusOut
). -
Alarm events that are triggered by an alert status.
-
Events that are triggered when the tab is changed (
SelectionChanged
). -
Events that are triggered when panels are closed (
Terminate
). -
Events that are triggered when the language is changed (
LangChanged
). -
Events that are triggered when the mouse is moved over an object.
DoubleClicked
exists for a button but it is executed
through a click, meaning there is no difference between a single and a double click.
For tables, radio and check boxes, we also recommend to use either the event
Clicked
or DoubleClicked
.setInputFocus()
function in scripts for
KeyboardFocusIn
.
Notes
Acknowledge
through the wizards. Since this script is used for
alarms, it has to have a specific format and cannot be edited with the script
editor.KeyboardFocusOut
(KeyboardFocusOut
of the
shape that loses the focus and Clicked
of the shape that gets the
focus), then WinCC OA ensures that the
KeyboardFocusOut
script will be started first.KeyboardFocusOut
and KeyboardFocusIn
scripts.Clicked
but Changed
.Wheel Event Example
The following example demonstrates how the Wheel
event could be used
to zoom your panel.
main(mapping event)
{
float factor = (event.angleDelta.y / 120.0) * 1.1;
if ( factor > 0.0 )
panelZoomIn(myModuleName(), factor, event.localPos);
else
panelZoomOut(myModuleName(), -factor, event.localPos);
}