DgsGetCursorPosition: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
Line 13: Line 13:


===Returns===
===Returns===
Returns two ''number''s indicates x and y coordinate if successful, ''false'' otherwise. If '''dgsElement''' is a DGS 3D Interface, you will get 3 extra ''number'' as world position ( x, y, z ) and 1 extra bool indicates if the mouse is inside the 3d interface.
Returns two ''number''s indicates x and y coordinate if successful, ''false'' otherwise. If '''dgsElement''' is a DGS 3D Interface, you will get 3 extra ''number'' as world position ( x, y, z ) and 1 extra ''bool'' indicates if the mouse is inside the 3d interface.


==Example==  
==Example==  

Revision as of 04:53, 8 January 2023

This function gets the position of the cursor and can be relative to a dgs element.

Syntax

float/int, float/int [, float, float, float, bool ]  dgsGetCursorPosition ( [ element dgsElement, bool relative ] )

Required Arguments

  • dgsElement: The dgs element that you want to relative to.
  • relative: This is whether positioning are relative. If this is true, then all width,height floats must be between 0 and 1, representing positions as a fraction of the dgsElement size. If false, then the co-ordinates will be absolute pixels on screen.

Returns

Returns two numbers indicates x and y coordinate if successful, false otherwise. If dgsElement is a DGS 3D Interface, you will get 3 extra number as world position ( x, y, z ) and 1 extra bool indicates if the mouse is inside the 3d interface.

Example

This example creates a dgs window and brings it on top.

DGS = exports.dgs

local window = DGS:dgsCreateWindow ( 0.4, 0.4, 0.3, 0.3, "Window", true )
addEventHandler("onClientRender",root,function()
	local x,y = DGS:dgsGetCursorPosition(window)
	dgsSetText(window,"X:"..x..";"Y:"..y)
end)

See Also

Custom Cursor Functions

Multi Language Supports

Animation

3D Element

3D Interface

3D Line

3D Image

3D Text

Browser

Button

Check Box

Combo Box

Custom Renderer

Edit

Detect Area

Drag'N Drop

Grid List

Image

Memo

Menu

Label

Layout

Line

Progress Bar

Radio Button

Scale Pane

Scroll Bar

Scroll Pane

Selector

Style

Switch Button

Tab Panel

Window

Basic Shape Plugins

Circle

Quadrilateral

Rounded Rectangle

Other Plugins

Blur Box

Canvas

Chart

Color Picker

Effect 3D

Gradient

Mask

Media Browser

Nine Slice

Object Preview Supports

Paste Handler

QRCode

Remote Image

Screen Source

SVG

Tooltips