Using point and click – PB Docs 70

Using point and click

Users can click graphs during execution. PowerScript provides
a function called ObjectAtPointer that stores information about
what was clicked. You can use this function in a number of ways
in Clicked scripts. For example, you can provide the user with the
ability to point and click on a data value in a graph and see information
about the value in a message box. This section shows you how.

Clicked events and graphs

To cause actions when a user clicks a graph, you write a Clicked
script for the graph control. The control must be enabled. Otherwise,
the Clicked event doesn’t occur.

Using ObjectAtPointer

ObjectAtPointer has the following syntax.

You should call ObjectAtPointer in the first statement of
a Clicked script.

When called, ObjectAtPointer does three things:

  • It returns the kind of object
    clicked on as a grObjectType enumerated value. For example, if the
    user clicks on a data point, ObjectAtPointer returns TypeData!.
    If the user clicks on the graph’s title, ObjectAtPointer returns
    TypeTitle!.
    For a complete list of the enumerated values of grObjectType,
    open the Browser and click the Enumerated tab.
  • It stores the number of the series the pointer was
    over in the variable seriesNumber
    , which is
    an argument passed by reference.
  • It stores the number of the data point in the variable dataNumber
    ,
    also an argument passed by reference.

After you have the series and data point numbers, you can
use other graph functions to get or provide information. For example,
you might want to report to the user the value of the clicked data
point.

Example

Assume there is a graph gr_sale in a window. The
following script for gr_sale’s Clicked event displays
a message box:

  • If the user
    clicks on a series (that is, if ObjectAtPointer returns TypeSeries!),
    the message box shows the name of the series clicked on. The script
    uses the function SeriesName to get the series name, given the series
    number stored by ObjectAtPointer.
  • If the user clicks on a data point (that is, if
    ObjectAtPointer returns TypeData!), the message box lists the name
    of the series and the value clicked on. The script uses GetData
    to get the data’s value, given the data’s series
    and data point number:


Document get from Powerbuilder help
Thank you for watching.
Was this article helpful?
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x