DxButton: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
m (PandFort moved page DxButton to DxButton-esp)
(Undo revision 74566 by PandFort (talk))
Tag: Undo
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
__NOTOC__  
__NOTOC__  
{{Client function}}
{{Client function}}
This function allows creation of a Modern DX Library Button, which is a clickable item as part of GUI.
Esta función permite la creación de un botón de biblioteca Modern DX, que es un elemento en el que se puede hacer clic como parte de la GUI.


'''Notice: This is a function exported by Modern DX Library!'''
'''Aviso: Esta es una función exportada por Modern DX Library!'''


==Syntax==  
==Syntax==  
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
element dxButton( float x, float y, float width, float height, string text [, element parent = nil, bool rounded = nil )
element dxButton( int x, int y, int width, int height, string text [, element parent = nil, bool rounded = nil )
</syntaxhighlight>  
</syntaxhighlight>  


===Required Arguments===  
===Required Arguments===  
[[Image:DGS_Button.png|thumb|DGS Button]]
[[Image:DGS_Button.png|thumb|DGS Button]]
*'''x:''' A float of the 2D x position of the button on a player's screen.
*'''x:''' Un numero de la posición 2D x del botón en la pantalla de un jugador.
*'''y:''' A float of the 2D y position of the button on a player's screen.
*'''y:''' Un numero de la posición 2D y del botón en la pantalla de un jugador.
*'''width:''' A float of the width of the button.
*'''width:''' Un numero del ancho del botón.
*'''height:''' A float of the height of the button.
*'''height:''' Un numero de la altura del botón.
*'''text:''' A string of the text that will be displayed as a label on the button.
*'''text:''' Una cadena del texto que se mostrará como una etiqueta en el botón.


===Optional Arguments===  
===Optional Arguments===  
{{OptionalArg}}  
{{OptionalArg}}  
*'''parent:''' This is the parent that the Modern DX Library button is attached.
*'''parent:''' Este es el padre que el Modern DX Library El botón está adjunto.
*'''rounded:''' Whether you want the button to be rounded or not. ( true or false )
*'''rounded:''' Si desea que el botón sea redondeado o no. ( true or false )


===Returns===
===Returns===
Returns an [[element]] of the created [[Element/Modern DX Library/Button|button]] if it was successfully created, false otherwise.
Devuelve un [[element]] del [[Element/Modern DX Library/Button|button]] creado si se creó con éxito; de lo contrario, devuelve falso.


==Example==  
==Example==  
This example creates an edit box alongside an "Output!" button. When the button is clicked, it will output the message in the edit box into the Chat Box.
Este ejemplo crea un cuadro de edición junto con un "¡Salida!" botón. Cuando se hace clic en el botón, se mostrará el mensaje en el cuadro de edición en el cuadro de chat.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
dxLibrary = exports[ "dxLibrary" ]
dxLibrary = exports[ "dxLibrary" ]


--create our button
-- crea un boton
button = dxLibrary:dxButton( 276, 80, 100, 40, "Output!" )
button = dxLibrary:dxButton( 276, 80, 100, 40, "Anunciar!" )


--Create an edit box and define it as "editBox".
-- cree un cuadro de edición y lo definimos como "editBox".
editBox = dxLibrary:dxEdit( 277, 184, 197, 46, "Type your message here!" )
editBox = dxLibrary:dxEdit( 277, 184, 197, 46, "Escribe tu mensaje aqui!" )


-- and attach our button to the outputEditBox function
-- y adjunte nuestro botón a la función outputEditBox
addEventHandler ( "onClick", editBox, outputEditBox )
addEventHandler ( "onClick", editBox, outputEditBox )


--setup our function to output the message to the chatbox
--configurar nuestra función para enviar el mensaje al chatbox
function outputEditBox ()
function outputEditBox ()
         local text = dxLibrary:dxGetText( editBox ) --get the text from the edit box
         local text = dxLibrary:dxGetText( editBox ) --Obtener el texto del cuadro de edición
         outputChatBox ( text, 255, 255, 255 ) --output that text
         outputChatBox ( text, 255, 255, 255 ) --anunciar ese texto
end
end
addEventHandler ( "onClick", button, outputEditBox )
addEventHandler ( "onClick", button, outputEditBox )
Line 49: Line 49:
</syntaxhighlight>
</syntaxhighlight>


==See Also==
==Ver también==
{{DXLIB_FUNCTIONS}}
{{DXLIB_FUNCTIONS}}

Revision as of 03:39, 11 May 2022

Esta función permite la creación de un botón de biblioteca Modern DX, que es un elemento en el que se puede hacer clic como parte de la GUI.

Aviso: Esta es una función exportada por Modern DX Library!

Syntax

element dxButton( int x, int y, int width, int height, string text [, element parent = nil, bool rounded = nil )

Required Arguments

DGS Button
  • x: Un numero de la posición 2D x del botón en la pantalla de un jugador.
  • y: Un numero de la posición 2D y del botón en la pantalla de un jugador.
  • width: Un numero del ancho del botón.
  • height: Un numero de la altura del botón.
  • text: Una cadena del texto que se mostrará como una etiqueta en el botón.

Optional Arguments

NOTE: When using optional arguments, you might need to supply all arguments before the one you wish to use. For more information on optional arguments, see optional arguments.

  • parent: Este es el padre que el Modern DX Library El botón está adjunto.
  • rounded: Si desea que el botón sea redondeado o no. ( true or false )

Returns

Devuelve un element del button creado si se creó con éxito; de lo contrario, devuelve falso.

Example

Este ejemplo crea un cuadro de edición junto con un "¡Salida!" botón. Cuando se hace clic en el botón, se mostrará el mensaje en el cuadro de edición en el cuadro de chat.

dxLibrary = exports[ "dxLibrary" ]

-- crea un boton
button = dxLibrary:dxButton( 276, 80, 100, 40, "Anunciar!" )

-- cree un cuadro de edición y lo definimos como "editBox".
editBox = dxLibrary:dxEdit( 277, 184, 197, 46, "Escribe tu mensaje aqui!" )

-- y adjunte nuestro botón a la función outputEditBox
addEventHandler ( "onClick", editBox, outputEditBox )

--configurar nuestra función para enviar el mensaje al chatbox
function outputEditBox ()
        local text = dxLibrary:dxGetText( editBox ) --Obtener el texto del cuadro de edición
        outputChatBox ( text, 255, 255, 255 ) --anunciar ese texto
end
addEventHandler ( "onClick", button, outputEditBox )

Ver también

General Functions

Window

Button

CheckBox

Edit

GridList

Image

Label

List

ProgressBar

ScrollBar