Promotic
WikipediaLinkedInYoutubeTwitterFacebook

onMouseArea - event of object TrendsView

Description:
The event fires on pressing, releasing or double-clicking the left mouse button on the graphic area, where the trend graphs are drawn in (bordered by scales). The fact if the event has been fired by pressing, releasing or by double-clicking can be obtained from the Action parameter.
Parameters:
pMe(Object) Reference to the PmiAx object that owns this ActiveX. The reference to the ActiveX object itself can be obtained by the pMe.Acx expression.
Action(Long) action type of the left mouse button
0 - releasing the left mouse button
1 - pressing the left mouse button
2 - double-clicking the left mouse button
Ctrl(Boolean) indication of concurrent pressing the Ctrl key
Shift(Boolean) indication of concurrent pressing the Shift key
Alt(Boolean) indication of concurrent pressing the Alt key
X(Long) Position of the mouse cursor (in pixels) in the X-coordinate relatively to the left upper corner of the area for drawing the trends (bordered by scales)
Y(Long) Position of the mouse cursor (in pixels) in the Y-coordinate relatively to the left upper corner of the area for drawing the trends (bordered by scales)
TimePos(Variant) Time value that refers to the curson position where it was clicked by the mouse.
ValuePos(Variant) Value of the active trend (specified by the TrendsView.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 TrendsView.TrendsCount property is 0), then the parameter is set to the value Empty.

Note:

Caution 1: It is always necessary to check the Action property (see Example1). If it wasn't checked, then the script in the onMouseArea event would be called twice because when the user presses or releases the mouse button, then the onMouseArea event fires 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 Action=1 action is treated. If such method is used, it can result in consequently NOT calling the Action=0 action. Scripts that open other windows must be handled in the branch belonging to mouse button release action (i.e. if Action=0).

See also:
Example1:
If Action = 0 Then
  If Ctrl Then
    ' 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
  End If
End If
Example2:
Clicking the mouse button close to the trend progression activates this trend, i.e. it sets the TrendActive property for the trend that has been clicked.
Dim nTrend
If Action = 0 Then
  nTrend = oTView.FindTrend(10, X, Y)
  If nTrend>= 0 Then
    oTView.TrendActive = nTrend
  End If
End If
© MICROSYS, spol. s r. o.Tavičská 845/21 703 00 Ostrava-Vítkovice