Promotic
WikipediaLinkedInYoutubeTwitterFacebook

onMouseArea - event of the PmgTrendViewer object

Description:
The event is triggered after pressing, releasing or double-clicking by the left mouse button on the graphic area, where the trend graphs are drawn in (bordered by scales).

The fact if the event is triggered by pressing, releasing or by mouse double-clicking can be obtained in the pEvent.Action parameter.

Parameters:
pMe(Object) Reference to the PmgTrendViewer object where the event rises.
pEvent(Object) Reference to object describing detailed information about the specific event.
pEvent.Action - (Long) action type of the left mouse button
0: releasing the button
1: pressing the button
2: double-clicking the button
pEvent.Ctrl - (Boolean) indication of concurrent pressing the Ctrl key
pvent.Shift - (Boolean) indication of concurrent pressing the Shift key
pEvent.Alt - (Boolean) indication of concurrent pressing the Alt key
pEvent.X - (Long) Position of the mouse cursor (in pixels) in the X-coordinate relative to the left upper corner of the area for drawing the trends (bordered by scales)
pEvent.Y - (Long) Position of the mouse cursor (in pixels) in the Y-coordinate relative to the left upper corner of the area for drawing the trends (bordered by scales)
pEvent.TimePos - (Variant) Time value that refers to the curson position where it was clicked by the mouse.
pEvent.ValuePos - (Variant) Value of the active trend (specified by the PmgTrendViewer.TrendActive property) that refers to the cursor position where it was clicked by the mouse.

If no trend is displayed in the viewer (the value of the PmgTrendViewer.TrendsCount property is 0), then the parameter is set to the value: null for JavaScript or Empty pro VBScript.

Note:

Caution 1: It is always necessary to check the pEvent.Action parameter (see Example1). If it wasn't checked, then the script in the onMouseArea event would be called twice because if the user presses or releases the mouse button, then the onMouseArea event is triggered twice but always with the different Action parameter.

Caution 2: It is NOT advisable to place methods that call another window on the workspace (e.g. Pm.InputBox, etc.), into the script when the pEvent.Action=1 action is treated. If such method is used, then it can result in consequently NOT calling the pEvent.Action=0 action. Scripts that open other windows must be handled in the branch belonging to mouse button release action (i.e. if pEvent.Action=0).

See also:
Example1:
JavaScriptVBScriptSelect and copy to clipboard

var oTrend = pMe.Trends(1);
if (Action == 0)
{
if (Ctrl)
{
//remove the nearest point to the cursor position when the mouse button is released
oTrend.Points.RemovePoints("range:all;time:near;", timePos);
}
else
{
//add point on the cursor position when the mouse button is released
oTrend.Points.AddPoints(timePos, ValuePos, 0, 5);
}
}
Example2:
by clicking the mouse close to the trend progression activates this trend, i.e. the TrendActive property is set to the trend that has been clicked.
JavaScriptVBScriptSelect and copy to clipboard

var oTView = pMe;
var nTrend;
if (Action == 0)
{
nTrend = oTView.FindTrend(10, X, Y);
if (nTrend >= 0)
oTView.TrendActive = nTrend;
}

History:
Pm8.01.07: The pEvent.Alt parameter did not set properly with Alt key pressed.
PROMOTIC 9.0.15 SCADA system documentation - MICROSYS, spol. s r.o.

Send page remarkContact responsible person
© MICROSYS, spol. s r. o.Tavičská 845/21 703 00 Ostrava-Vítkovice