Download Simscript III Graphics Manual

Transcript
3.6 Reading Mouse Input Synchronously
Input from a Window object can also be handled synchronously. The method
accept_input blocks execution until the user clicks in the canvas of the window. An
anchored rubber band cursor which tracks the pointer can be shown. accept_input
yields both the (x,y) coordinates of the mouse click, and a pointer to the View that was
clicked in. These coordinates are bounded by the coordinate system assigned to the
yielded View.
accept_input parameters include the (x,y) location (in NDC coordinates) of the anchor
point of the cursor as well as an integer representing the cursor style. Available cursors
are shown in the table below.
CONSTANT
DESCRIPTION
_cursor_none
Do not show a cursor.
_cursor_line
Show a rubber band line anchored at the given anchor point. The line is
updated automatically as the mouse is moved.
_cursor_box
Show a rubber band box anchored at the given anchor point. The corner of
the box is updated automatically as the mouse is moved.
_cursor_icon
Use this cursor style if a Graphic object should be moved with the mouse.
The object should be provided as a parameter.
3.7 Using a Window
If the full features of a Window need to be employed in the application, the following
steps should be taken into account:
1. In your preamble, subclass the Window object and override its action method.
2. In the action method, write code to check the id attribute of the given
WindowEvent and respond accordingly.
3. In the program initialization, create your Window object and assign properties
such as position, title etc.
4. Add instances of View object(s) to the view_set. Add Graphic object(s) to the
graphic_set owned by the View.
5. Call the display method to show the window. Objects filed into the view_set
will also be shown.
The following example shows a window with scroll bars and a status bar. In this
example the action method is overridden, allowing the events and associated data to be
reported through a dialog box.
19