system.ui.<...>

Return to Introduction  Previous page  Next page

User interface functions for controlling mouse, keyboard and joystick input.

 

Properties

 

mouse

Has properties x, y and button that represent the current position of the mouse relative to the top left of the player window, and which mouse button(s) are down.  Also returns hitInfo which gives details of the actual subgroup/face the mouse is over for a mesh.  Methods show() and hide() will show/hide the cursor.

joystick

Has properties x, y, z and button that represent the current position of the joystick where 0.0,0.0,0.0 is the joystick in the centre.  Values range from -1.0 to 1.0 along each axis.  As joysticks often do not return to the absolute centre, a property zeroRange can be set to determine how far a joystick must move along an axis before it is registered.  The default is 0.2.  Advanced properties rx,ry,rz, pov0, pov1, pov2, pov3 and slider0, slider1 are also available.

mouseLookObject

Gets or sets the object that will be controlled by dragging the right mouse button in the player window.

keyboardMoveObject

Gets or sets the object that will be controlled by pressing the cursor keys.

desktopWidth

Width of the user's desktop in pixels.

desktopHeight

Height of the user's desktop in pixels.

 

Methods

 

paletteDialog(initialcol)

Brings up a modal color selection box (pauses script execution).  Returns a Color value if OK is pressed, or null if cancelled.  Pass a Color as a parameter to give a default.

 

Examples

 

print("Mouse x position is: "+system.ui.mouse.x);

 

system.ui.mouseLookObject=scenes.scene_1.objects.camera_1; // Control the camera in scene_1 with the mouse.

 

// script for a camera object in a 3D scene

var speed=10.0;

function onUpdate()

{

       if (system.ui.mouse.button==1)

       {

               object.pos.x+=system.timerDelta*speed; // move along the x axis, accounting for the frame update rate.

       }

}

 

// Check which buttons are down

function onUpdate()

{

       for(var buttonIndex=0;buttonIndex<31;buttonIndex++)

       {

               if (system.ui.joystick.button & Math.pow(2,buttonIndex))

               {

                       print("Button "+buttonIndex+" is down");

               }

       }

}

 

Remarks

 

All mouse x/y coordinates are in pixels.

 

See Also

 

System



Copyright ©2004 Worldweaver Ltd. DX Studio Home