Chapter Contents

Previous

Next
Widget Class: _cursorTracker

Widget Class: _cursorTracker



Invoked when cursor tracking is enabled and the mouse pointer is moved across a widget


Syntax
Details

Syntax

objectName._cursorTracker( x, y );

Argument Type Use Description
x Numeric Output returns the mouse pointer position in pixels relative to the upper left corner of the widget's region (0,0)
y Numeric Output returns the mouse pointer position in pixels relative to the upper left corner of the widget's region (0,0)


Details

As you move the mouse to the right, the x value grows. As you move the mouse pointer down, the y value grows. Because region outlines are considered part of the region but are drawn on the outside edge of the region, you can get negative values for x and y when the mouse pointer is on the top or left border of the region. When the mouse pointer is on the bottom or right border of the region, you can also get values for x and y that exceed the region size. This is more noticeable when the region outline width is large.

Some hosts do not allow the _cursorTracker method to be invoked while the mouse pointer is moving across native widgets (for example, list boxes, push buttons, and icons).

Example

Set the cursor shape for the container box object, obj1, to a crosshair and enable cursor tracking. The _cursorTracker method prints whether the mouse pointer is on the region outline or inside the region. The code for _cursorTracker is assumed to be in Sasuser.Example.Methods.scl.

length msg $40;

TRACKER:
 method x y 8;
  _self_._getObjectSize(width, height,'pixels');
  if (x < 0 or y < 0 or x > width or y > height) then
    msg = 'You are on the region border';
  else
    msg = 'You are in the region';
  _frame_._setMsg(msg||'('||x||','||y||')');
 endmethod;

For this code to run, cursor tracking must be enabled. Instead of making a container box subclass, the _setInstanceMethod method is used:

INIT:
 obj1._setInstanceMethod._cursorTracker
 (sasuser.example.methods,tracker); obj1._cursorTrackingOn();
 obj1._setCursorShape(3);
return;

When the mouse pointer is moved over the container box, the message line indicates the following or something similar:

 You are in the region (32,55)

or

 You are on the region border (-2,46)


Chapter Contents

Previous

Next

Top of Page

Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.