Attention: Here be dragons
This is the latest
(unstable) version of this documentation, which may document features
not available in or compatible with released stable versions of Godot.
Checking the stable version of the documentation...
LineEdit¶
Inherits: Control < CanvasItem < Node < Object
Control que proporciona la edición de string de una sola línea.
Descripción¶
LineEdit provides a single-line string editor, used for text fields.
It features many built-in shortcuts which will always be available (Ctrl
here maps to Command
on macOS):
Ctrl + C: Copy
Ctrl + X: Cut
Ctrl + V or Ctrl + Y: Paste/"yank"
Ctrl + Z: Undo
Ctrl + Shift + Z: Redo
Ctrl + U: Delete text from the cursor position to the beginning of the line
Ctrl + K: Delete text from the cursor position to the end of the line
Ctrl + A: Select all text
Up/Down arrow: Move the cursor to the beginning/end of the line
On macOS, some extra keyboard shortcuts are available:
Ctrl + F: Like the right arrow key, move the cursor one character right
Ctrl + B: Like the left arrow key, move the cursor one character left
Ctrl + P: Like the up arrow key, move the cursor to the previous line
Ctrl + N: Like the down arrow key, move the cursor to the next line
Ctrl + D: Like the Delete key, delete the character on the right side of cursor
Ctrl + H: Like the Backspace key, delete the character on the left side of the cursor
Command + Left arrow: Like the Home key, move the cursor to the beginning of the line
Command + Right arrow: Like the End key, move the cursor to the end of the line
Propiedades¶
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
focus_mode |
|
|
|
||
mouse_default_cursor_shape |
|
|
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
Métodos¶
void |
append_at_cursor ( String text ) |
void |
clear ( ) |
void |
|
void |
delete_text ( int from_column, int to_column ) |
void |
deselect ( ) |
get_menu ( ) const |
|
get_scroll_offset ( ) const |
|
void |
menu_option ( int option ) |
void |
|
void |
select_all ( ) |
Propiedades del Theme¶
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
Señales¶
text_change_rejected ( String rejected_substring )
Emitted when appending text that overflows the max_length. The appended text is truncated to fit max_length, and the part that couldn't fit is passed as the rejected_substring
argument.
text_changed ( String new_text )
Emitido cuando el texto cambia.
text_entered ( String new_text )
Emitido cuando el usuario presiona @GlobalScope.KEY_ENTER en la LineEdit
.
Enumeraciones¶
enum Align:
ALIGN_LEFT = 0 --- Alinea el texto en el lado izquierdo de la
LineEdit
.ALIGN_CENTER = 1 --- Centra el texto en el centro de la
LineEdit
.ALIGN_RIGHT = 2 --- Alinea el texto en el lado derecho de la
LineEdit
.ALIGN_FILL = 3 --- Estira los espacios en blanco para que se ajusten al ancho de la
LineEdit
.
MENU_CUT = 0 --- Corta (copia y borra) el texto seleccionado.
MENU_COPY = 1 --- Copia el texto seleccionado.
MENU_PASTE = 2 --- Pega el texto del portapapeles sobre el texto seleccionado (o en la posición del cursor).
Los caracteres de escape no imprimibles se eliminan automáticamente del portapapeles del sistema operativo a través del String.strip_escapes.
MENU_CLEAR = 3 --- Borra todo el texto
LineEdit
.MENU_SELECT_ALL = 4 --- Selecciona todo el texto
LineEdit
.MENU_UNDO = 5 --- Deshace la acción anterior.
MENU_REDO = 6 --- Invierte la última acción de deshacer.
MENU_MAX = 7 --- Representa el tamaño del enum MenuItems.
Descripciones de Propiedades¶
Align align
Default |
|
Setter |
set_align(value) |
Getter |
get_align() |
Alineación del texto como se define en el enum Align.
bool caret_blink
Default |
|
Setter |
cursor_set_blink_enabled(value) |
Getter |
cursor_get_blink_enabled() |
Si true
, el caret (cursor visual) parpadea.
float caret_blink_speed
Default |
|
Setter |
cursor_set_blink_speed(value) |
Getter |
cursor_get_blink_speed() |
Duración (en segundos) del ciclo de parpadeo de un caret.
int caret_position
Default |
|
Setter |
set_cursor_position(value) |
Getter |
get_cursor_position() |
La posición del cursor dentro de la LineEdit
. Cuando se ajusta, el texto puede desplazarse para acomodarlo.
bool clear_button_enabled
Default |
|
Setter |
set_clear_button_enabled(value) |
Getter |
is_clear_button_enabled() |
Si true
, el LineEdit
mostrará un botón de borrado si text
no está vacío, que puede utilizarse para borrar el texto rápidamente.
Default |
|
Setter |
set_context_menu_enabled(value) |
Getter |
is_context_menu_enabled() |
Si true
, el menú contextual aparecerá al hacer clic con el botón derecho del ratón.
bool editable
Default |
|
Setter |
set_editable(value) |
Getter |
is_editable() |
Si false
, el texto existente no puede ser modificado y no se puede añadir un nuevo texto.
bool expand_to_text_length
Default |
|
Setter |
set_expand_to_text_length(value) |
Getter |
get_expand_to_text_length() |
Si true
, el ancho de LineEdit
aumentará para permanecer más tiempo que el text.No se comprimirá si el text se acorta.
int max_length
Default |
|
Setter |
set_max_length(value) |
Getter |
get_max_length() |
Maximum amount of characters that can be entered inside the LineEdit
. If 0
, there is no limit.
When a limit is defined, characters that would exceed max_length are truncated. This happens both for existing text contents when setting the max length, or for new text inserted in the LineEdit
, including pasting. If any input text is truncated, the text_change_rejected signal is emitted with the truncated substring as parameter.
Example:
text = "Hello world"
max_length = 5
# `text` becomes "Hello".
max_length = 10
text += " goodbye"
# `text` becomes "Hello good".
# `text_change_rejected` is emitted with "bye" as parameter.
float placeholder_alpha
Default |
|
Setter |
set_placeholder_alpha(value) |
Getter |
get_placeholder_alpha() |
Opacidad del placeholder_text. De 0
a 1
.
String placeholder_text
Default |
|
Setter |
set_placeholder(value) |
Getter |
get_placeholder() |
El texto se muestra cuando la LineEdit
está vacía. Es no el valor por defecto de LineEdit
(véase el text).
Texture right_icon
Setter |
set_right_icon(value) |
Getter |
get_right_icon() |
Establece el icono que aparecerá en el extremo derecho de la LineEdit
si no hay text, o siempre, si clear_button_enabled está establecido en false
.
bool secret
Default |
|
Setter |
set_secret(value) |
Getter |
is_secret() |
Si true
, cada carácter se sustituye por el carácter secreto (véase secret_character).
String secret_character
Default |
|
Setter |
set_secret_character(value) |
Getter |
get_secret_character() |
El carácter que se usará para enmascarar la entrada secreta (por defecto es "*"). Sólo se puede utilizar un único carácter como el carácter secreto.
bool selecting_enabled
Default |
|
Setter |
set_selecting_enabled(value) |
Getter |
is_selecting_enabled() |
Si false
, es imposible seleccionar el texto usando el ratón o el teclado.
bool shortcut_keys_enabled
Default |
|
Setter |
set_shortcut_keys_enabled(value) |
Getter |
is_shortcut_keys_enabled() |
Si false
, el uso de atajos se desactivará.
String text
Default |
|
Setter |
set_text(value) |
Getter |
get_text() |
Valor de la strting de la LineEdit
.
Nota: Cambiar el texto usando esta propiedad no emitirá la señal text_changed.
bool virtual_keyboard_enabled
Default |
|
Setter |
set_virtual_keyboard_enabled(value) |
Getter |
is_virtual_keyboard_enabled() |
Si true
, el teclado virtual nativo se muestra cuando se enfoca en plataformas que lo soportan.
Descripciones de Métodos¶
void append_at_cursor ( String text )
Añade text
después del cursor. Si el valor resultante es mayor que max_length, no pasa nada.
void clear ( )
Borra el text de LineEdit
.
void delete_char_at_cursor ( )
Deletes one character at the cursor's current position (equivalent to pressing the Delete
key).
Elimina una sección del text que va de la posición from_column
a to_column
. Ambos parámetros deben estar dentro de la longitud del texto.
void deselect ( )
Borra la selección actual.
Returns the PopupMenu of this LineEdit
. By default, this menu is displayed when right-clicking on the LineEdit
.
Warning: This is a required internal node, removing and freeing it may cause a crash. If you wish to hide it or any of its children, use their CanvasItem.visible property.
int get_scroll_offset ( ) const
Returns the scroll offset due to caret_position, as a number of characters.
Ejecuta una acción determinada según se define en el enum MenuItems.
Selecciona los caracteres dentro de LineEdit
entre from
y to
. Por defecto, from
está al principio y to
al final.
text = "Bienvenido"
select() # Seleccionará "Bienvenido".
select(4) # Seleccionará "venido".
select(2, 5) # Seleccionará "env".
void select_all ( )
Selecciona toda la String.
Theme Property Descriptions¶
Color clear_button_color
Default |
|
Color utilizado como tinte predeterminado para el botón de despejar.
Color clear_button_color_pressed
Default |
|
Color usado para el botón de borrado cuando se presiona.
Color cursor_color
Default |
|
Color del cursor visual (caret) de la LineEdit
.
Color font_color
Default |
|
Color de fuente predeterminado.
Color font_color_selected
Default |
|
Color de fuente para el texto seleccionado (dentro del rectángulo de selección).
Color font_color_uneditable
Default |
|
El color de la fuente cuando la edición está desactivada.
Color selection_color
Default |
|
Color del rectángulo de selección.
int minimum_spaces
Default |
|
Espacio horizontal mínimo para el texto (sin contar el botón de borrar y los márgenes de contenido). Este valor se mide en el recuento de caracteres de espacio (es decir, esta cantidad de caracteres de espacio pueden ser mostrados sin desplazamiento).
Font font
Fuente usada para el texto.
Texture clear
La textura para el botón de despejar. Ver clear_button_enabled.
StyleBox focus
Fondo utilizado cuando LineEdit
tiene el enfoque de la interfaz gráfica de usuario(GUI).
StyleBox normal
Fondo predeterminado para la LineEdit
.
StyleBox read_only
Fondo utilizado cuando LineEdit
está en modo de sólo lectura (editable está configurado como false
).