Satimage Previous | Next
pick in
Home Documentation SmileLab Scripting Customizing graph's interface pick in  
  • When the user clicks in a graphic view, or in a graphic window out of any graphic view, and as long as the mouse button is pressed, Smile sends the following event to the script of the graphic window or of the concerned graphic view.
    pick in the_object at the_record
    the_object is a reference to the owner of the script.
    the_record can contain up to three fields: point, step and target object.
    point contains a list of two real numbers, the coordinates of the mouse location.
    if the click first occurred inside the boundaries of a 1-d or a 2-d plot, the coordinates are in user units, that is, in the system of coordinates of the axes.
    if the click first occurred over a surface in a 3-d plot (view3d), the coordinates are three numbers, the location in user units of the point of the surface where the click occurred, as long as the mouse is over the surface.
    if the click first occurred out of any plot (and even if the mouse is currently over a plot), the coordinates are in pixels, in the system of coordinates of the graphic window.
    step is an integer which takes the following values:
    • 1: the user pressed the mouse button down (mouse down event)
    • 2: the user is dragging the mouse: pick in is sent each time the location of the mouse is changed
    • 3: the user released the mouse button (mouse up event)
    • 4: send on double-click
    target object is a reference to the object which was clicked, and is present only in the two following cases.
    if the click first occurred over a surface in a 3-d plot, target object contains a reference to the surface
    if the click first occurred in a widget in a graphic window, target object contains a reference to the widget.
  • To retrieve coordinates in pixels when the point field is given in user units, use convert coordinates.
    on pick in the_view at the_record
        set userPt to point of the_record
        set pixelPt to convert coordinates userPt in the_view
    end pick in
  • The custom behavior that you may install by providing a pick in handler in an object's script will replace the built-in behavior (where the coordinates of the mouse are displayed in the Message floating window), unless you invoke the built-in behavior with the continue instruction like in the example presented below.
Example
The example below, if installed in the script of a plot view, will create a new point to a curve (that it will first create if necessary) each time the user clicks in the plot's frame.
on pick in the_view at the_record
    continue pick in the_view at the_record
    set theStep to step of the_record
    if theStep is not 1 then return
    set {x, y} to point of the_record
    try
        set c to curve 1 of the_view
    on error
        set c to make new curve at the_view
        set xdata of c to {0}
        set ydata of c to {0}
        set line style of c to 1
        set pattern style of c to 1
    end try
    set xdata of c to (get xdata of c) & {x}
    set ydata of c to (get ydata of c) & {y}
    set limits of the_view to {0, 1, 0, 1}
    draw the_view
end pick in


Import script
To experiment with the script above, proceed as follows.
  • Run first the script below, which will create the plot.
    set w to make new graphic window
    make new plot view at w
  • Select Graphs ▸ Edit script then choose the plot view. This will open the plot view's script.
  • Paste the script above, then save and close the script window with the File menu.
Now click anywhere in the plot to create new points.
Copyright ©2008 Paris, Satimage