OnDgsMouseClickDown
From Multi Theft Auto: Wiki
This event happens when any dgs-element clicked ( Mouse down ).
And this event is for those who are converting gui to dgs.
Note: The player who clicked the dgs-element is always the localPlayer. |
Note: If you want to ask why everything is triggered... See the forth parameter of addEventHandler |
Parameters
string button, string state, int absoluteX, int absoluteY
- button: the name of the button which will be clicked , it can be left, right, middle
- 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.
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 ( "onDgsMouseClickDown", 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 ) if button == "left" 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 ) if button == "left" then outputChatBox ( "Hey bro, you clicked me, your state is "..state ) end end addEventHandler ( "onDgsMouseClickDown", btnOutput, outputEditBox )
See Also
DGS events
- onDgsArrowListValueChange
- onDgsBlur
- onDgsCheckBoxChange
- onDgsComboBoxStateChange
- onDgsComboBoxSelect
- onDgsCreate
- onDgsDestroy
- onDgsEditPreSwitch
- onDgsEditSwitched
- onDgsEditAccepted
- onDgsElementRender
- onDgsElementMove
- onDgsElementSize
- onDgsFocus
- onDgsGridListItemDoubleClick
- onDgsGridListSelect
- onDgsMouseClick
- onDgsMouseClickDown
- onDgsMouseClickUp
- onDgsMouseDrag
- onDgsMouseDoubleClick
- onDgsMouseDown
- onDgsMouseEnter
- onDgsMouseLeave
- onDgsMouseMove
- onDgsMouseUp
- onDgsMouseWheel
- onDgsRadioButtonChange
- onDgsPositionChange
- onDgsPreRender
- onDgsRender
- onDgsElementScroll
- onDgsSizeChange
- onDgsTabPanelTabSelect
- onDgsTabSelect
- onDgsTextChange
- onDgsWindowClose
Plugin
Media
- onDgsMediaPlay
- onDgsMediaPause
- onDgsMediaStop
- onDgsMediaDurationGet
- onDgsMediaTimeUpdate
- onDgsMediaBrowserReturn