OnDgsMouseClick: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
|||
Line 7: | Line 7: | ||
==Parameters== | ==Parameters== | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
string button, string state, int absoluteX, int absoluteY | string button, string state, int absoluteX, int absoluteY, bool isCoolingDown | ||
</syntaxhighlight> | </syntaxhighlight> | ||
*'''button:''' the name of the button which will be clicked , it can be ''left'', ''right'', ''middle'' | *'''button:''' the name of the button which will be clicked , it can be ''left'', ''right'', ''middle'' | ||
Line 13: | Line 13: | ||
*'''absoluteX:''' the X position of the mouse cursor, in pixels, measured from the left side of the screen. | *'''absoluteX:''' the X position of the mouse cursor, in pixels, measured from the left side of the screen. | ||
*'''absoluteY:''' the Y position of the mouse cursor, in pixels, measured from the top of the screen. | *'''absoluteY:''' the Y position of the mouse cursor, in pixels, measured from the top of the screen. | ||
*'''isCoolingDown:''' A bool indicates whether this dgs element is cooling down. See [[DGS_General_Basic_Properties#clickCoolDown]] | |||
==Source== | ==Source== | ||
The [[event system#Event source|source]] of this event is the DGS element that was clicked. | The [[event system#Event source|source]] of this event is the DGS element that was clicked. |
Revision as of 11:41, 12 February 2021
This event happens when any dgs-element clicked
Parameters
string button, string state, int absoluteX, int absoluteY, bool isCoolingDown
- button: the name of the button which will be clicked , it can be left, right, middle
- state: the state of the mouse button, will be down if the mouse button was pushed, or up if it was released. Please note currently both up and down state are supported, which is different from onClientGUIClick. For only up or down, see onDgsMouseClickUp/onDgsMouseClickDown
- absoluteX: the X position of the mouse cursor, in pixels, measured from the left side of the screen.
- absoluteY: the Y position of the mouse cursor, in pixels, measured from the top of the screen.
- isCoolingDown: A bool indicates whether this dgs element is cooling down. See DGS_General_Basic_Properties#clickCoolDown
Source
The source of this event is the DGS element that was clicked.
Example
This example creates an edit box alongside an "Output!" button. When the button is clicked with the left mouse button, it will output the message in the edit box into the chat box.
DGS = exports.dgs -- When client's resource starts, create the GUI function initGUI( ) -- Create our button btnOutput = DGS:dgsCreateButton( 0.7, 0.1, 0.2, 0.1, "Output!", true ) -- And attach our button to the outputEditBox function addEventHandler ( "onDgsMouseClick", btnOutput, outputEditBox ) -- Create an edit box and define it as "editBox". editBox = DGS:dgsCreateEdit( 0.3, 0.1, 0.4, 0.1, "Type your message here!", true ) end addEventHandler( "onClientResourceStart", getResourceRootElement( getThisResource( ) ), initGUI ) -- Setup our function to output the message to the chatbox function outputEditBox ( button, state ) if button == "left" and state == "down" then local text = DGS:dgsGetText( editBox )-- Get the text from the edit box outputChatBox ( text ) -- Output that text end end
Clear Example
DGS = exports.dgs btnOutput = DGS:dgsCreateButton( 0.7, 0.1, 0.2, 0.1, "Output!", true ) function outputEditBox ( button, state ) if button == "left" and state == "down" then outputChatBox ( "Hey bro, you clicked me, your state is "..state ) end end addEventHandler ( "onDgsMouseClick", btnOutput, outputEditBox )
See Also
DGS events
General
- onDgsBlur
- onDgsCreate
- onDgsCursorTypeChange
- onDgsCursorStateChange
- onDgsDestroy
- onDgsElementRender
- onDgsElementMove
- onDgsElementSize
- onDgsElementEnter
- onDgsElementLeave
- onDgsFocus
- onDgsKey
- onDgsPositionChange
- onDgsPreRender
- onDgsRender
- onDgsElementScroll
- onDgsSizeChange
- onDgsTextChange
- onDgsWindowClose
- onDgsPropertyChange
Check Box
Combo Box
Drag'N Drop
Edit
Grid List
Menu
Selector
Mouse
- onDgsMousePreClick
- onDgsMouseClick
- onDgsMouseClickDown
- onDgsMouseClickUp
- onDgsMouseDrag
- onDgsMouseDoubleClick
- onDgsMouseDoubleClickDown
- onDgsMouseDoubleClickUp
- onDgsMouseDown
- onDgsMouseHover
- onDgsMouseEnter
- onDgsMouseLeave
- onDgsMouseMultiClick
- onDgsMouseMove
- onDgsMouseStay
- onDgsMouseUp
- onDgsMouseWheel
Radio Button
Switch Button
Tab
Animation
Plugin
Media
- onDgsMediaPlay
- onDgsMediaPause
- onDgsMediaStop
- onDgsMediaLoaded
- onDgsMediaTimeUpdate
- onDgsMediaBrowserReturn
Color Picker
QRCode
Remote Image
Client event functions
- triggerLatentServerEvent
- triggerServerEvent
- Shared
- addEvent
- addEventHandler
- cancelEvent
- cancelLatentEvent
- getEventHandlers
- getLatentEventHandles
- getLatentEventStatus
- removeEventHandler
- triggerEvent
- wasEventCancelled