Click to go to the home page.

This Document
"6: Handle" Behavior
Public Handler

See Also
"6b: Handle" parent script
"Cursor Control" Behavior
Scene 12 of the demo

 

Site Nav

css drop down menu by Css3Menu.com

6: Handle

The "6: Handle" Behavior

Click to go to top of this section. What it does

You can see this behavior in scene 12 of the demo.

"6: Handle" makes a window or menu draggable. When you attach this to a Window Element or Menu Element, when the user mouses down on the element, they can drag the window or menu around as long as you also have a copy of the "6b: Handle" script in a cast. If you don't have a copy of this in a cast, WFS will remind you to do it because the "6: Handle" behavior needs the "6b: Handle" parent script.

If the behavior is attached to an element of a window and there are children of the window, then they will move also as long as the children are configured to move with their parent. Child windows have to be configured to move with their parent via their Manager's Parameter Dialog Box. Child menus automatically move with their parent.

When you make an element a handle, you may wish to drop the "Cursor Control" behavior on the element and configure the "Cursor Control" behavior so that it is set to "Drag and Drop" so the cursor indicates to the user that the handle sprite is draggable. You don't have to do this, but it is sound interface design.

Click to go to top of this section. What to attach it to

Attach "6: Handle" to Window Elements or Menu Elements (not to Managers). Window Elements and Menu Elements have the "4: Window/Menu Element" behavior attached to them.

You can attach multiple handles to a given window or menu, if you like (but only one per sprite).

Click to go to top of this section. "6b: Handle" parent script

If you use the "6: Handle" behavior, drop a copy of the "6b: Handle" parent script into a cast. You don't need to configure "6b: Handle" at all.

Click to go to top of this section. Parameter Dialog Box

If you leave the top box blank, you will be able to drag the window around without constraints. If you type in the name of a multi-sprite, then the multi-sprite to which the "6: Handle" behavior is attached will be constrained in its movement by the rectangle you define in the other four boxes. The values in the last four boxes are relative to the background of the multi-sprite you specify in the first box. Positive values are like page margins. Negative values broaden the borders.

You can specify two special values in the first box: "stage" or "parent" (without the quotation marks). If you specify "stage" then the multi-sprite will be constrained by the rectangle you define relative to the stage. Putting in four 0 values, for instance, would constrain the multi-sprite to the stage. If you specify "parent" in the first box, then the multi-sprite will be constrained by its parent, if it has one.

Click to go to top of document. Public Handler

wfsSetConstraints (constrainingWindow, theLeft, theTop, theRight, theBottom)

Function

wfsSetConstraints allows you to change the constraints on the fly.

Parameters

constrainingWindow: This is a string that is the name of a multi-sprite or you can also use "stage" or "parent". If you specify "stage" then the multi-sprite will be constrained by the rectangle you define via theLeft, theTop, the Right, and theBottom relative to the stage. Putting in four 0 values, for instance, would constrain the multi-sprite to the stage. If you specify "parent", then the multi-sprite will be constrained by its parent, if it has one. If you don't want any constraints, set constrainingWindow to "".

theLeft: This is an integer. It is only relevant if you have specified constrainingWindow to be the name of some multi-sprite or "stage" or "parent". Positive values for theLeft determine how far to the right of the left border of the constraining window the constraint will be. Negative values for theLeft let the user move the window further to the left than the constraining window's left border.

theTop: Same sort of idea as for theLeft only theTop determines the constraint concerning top vertical movement.

theRight: Same sort of idea as for theLeft only theTop determines the constraint concerning movement to the right

theBottom: Same sort of idea as for theLeft only theTop determines the constraint concerning vertical movement down.

Example

In the below examples, suppose that the "6: Handle" behavior is attached to sprite 7.

sprite(7).wfsSetConstraints("some window", 0,0,0,0)

The above constrains the window that the "6: Handle" behavior is part of to moving within the area defined by the background sprite of the multi-sprite named "some window". Recall that by WFS convention, the background of a multi-sprite is the area defined by the rect of the element below the manager in the Score.

sprite(7).wfsSetConstraints("stage", 0,0,0,0)

The above constrains the window that the "6: Handle" behavior is part of to moving within the area defined by the stage.

sprite(7).wfsSetConstraints("parent", 0,0,0,0)

The above constrains the window that the "6: Handle" behavior is part of to moving within the area defined by the parent of the multi-sprite, if it has one. If it doesn't have a parent, the multi-sprite will be unconstrained in its movement.

sprite(7).wfsSetConstraints("",1,2,3,4)

The above makes the multi-sprite unconstrained in its movement. The last four parameters are without effect since the first one is "".

sprite(7).wfsSetConstraints("stage", 20,-30,40,-50)

The above constrains the multi-sprite to movement within a rectangle whose left side is 20 pixels to the right of the left of the stage; 30 pixels higher than the top of the stage; 40 pixels to the left of the stage's right; and 50 pixels below the bottom of the stage.

 

Click to go to the home page6: Handle