Trait ILineEdit
pub trait ILineEdit: GodotClass<Base = LineEdit> + You_forgot_the_attribute__godot_api {
Show 32 methods
// Provided methods
fn init(base: Base<Self::Base>) -> Self { ... }
fn enter_tree(&mut self) { ... }
fn ready(&mut self) { ... }
fn exit_tree(&mut self) { ... }
fn process(&mut self, delta: f64) { ... }
fn physics_process(&mut self, delta: f64) { ... }
fn input(&mut self, event: Gd<InputEvent>) { ... }
fn shortcut_input(&mut self, event: Gd<InputEvent>) { ... }
fn unhandled_key_input(&mut self, event: Gd<InputEvent>) { ... }
fn unhandled_input(&mut self, event: Gd<InputEvent>) { ... }
fn on_notification(&mut self, what: ControlNotification) { ... }
fn on_get(&self, property: StringName) -> Option<Variant> { ... }
fn on_set(&mut self, property: StringName, value: Variant) -> bool { ... }
fn on_validate_property(&self, property: &mut PropertyInfo) { ... }
fn on_get_property_list(&mut self) -> Vec<PropertyInfo> { ... }
fn on_property_get_revert(&self, property: StringName) -> Option<Variant> { ... }
fn to_string(&self) -> GString { ... }
fn has_point(&self, point: Vector2) -> bool { ... }
fn structured_text_parser(
&self,
args: Array<Variant>,
text: GString,
) -> Array<Vector3i> { ... }
fn get_minimum_size(&self) -> Vector2 { ... }
fn get_tooltip(&self, at_position: Vector2) -> GString { ... }
fn get_drag_data(&mut self, at_position: Vector2) -> Variant { ... }
fn can_drop_data(&self, at_position: Vector2, data: Variant) -> bool { ... }
fn drop_data(&mut self, at_position: Vector2, data: Variant) { ... }
fn make_custom_tooltip(&self, for_text: GString) -> Option<Gd<Object>> { ... }
fn accessibility_get_contextual_info(&self) -> GString { ... }
fn get_accessibility_container_name(
&self,
node: Option<Gd<Node>>,
) -> GString { ... }
fn gui_input(&mut self, event: Gd<InputEvent>) { ... }
fn draw(&mut self) { ... }
fn get_configuration_warnings(&self) -> PackedArray<GString> { ... }
fn get_accessibility_configuration_warnings(&self) -> PackedArray<GString> { ... }
fn get_focused_accessibility_element(&self) -> Rid { ... }
}Expand description
§Interface trait for class LineEdit.
Functions in this trait represent constructors (init) or virtual method callbacks invoked by the engine.
§Related symbols
Base interfaces: IControl > > ICanvasItemINode > IObject.
(Strike-through means some intermediate Godot classes are marked final, and can thus not be inherited by GDExtension.)
See also Godot docs for LineEdit methods.
Provided Methods§
fn init(base: Base<Self::Base>) -> Self
fn init(base: Base<Self::Base>) -> Self
Godot constructor, accepting an injected base object.
base refers to the base instance of the class, which can either be stored in a Base<T> field or discarded.
This method returns a fully-constructed instance, which will then be moved into a Gd<T> pointer.
If the class has a #[class(init)] attribute, this method will be auto-generated and must not be overridden.
fn enter_tree(&mut self)
fn enter_tree(&mut self)
Called when the node enters the SceneTree (e.g. upon instantiating, scene changing, or after calling add_child in a script). If the node has children, its enter_tree callback will be called first, and then that of the children.
Corresponds to the NodeNotification::ENTER_TREE notification in on_notification.
fn ready(&mut self)
fn ready(&mut self)
Called when the node is “ready”, i.e. when both the node and its children have entered the scene tree. If the node has children, their ready callbacks get triggered first, and the parent node will receive the ready notification afterwards.
Corresponds to the NodeNotification::READY notification in on_notification. See also the @onready annotation for variables.
Usually used for initialization. For even earlier initialization, init may be used. See also enter_tree.
Note: This method may be called only once for each node. After removing a node from the scene tree and adding it again, ready will not be called a second time. This can be bypassed by requesting another call with request_ready, which may be called anywhere before adding the node again.
fn exit_tree(&mut self)
fn exit_tree(&mut self)
Called when the node is about to leave the SceneTree (e.g. upon freeing, scene changing, or after calling remove_child in a script). If the node has children, its exit_tree callback will be called last, after all its children have left the tree.
Corresponds to the NodeNotification::EXIT_TREE notification in on_notification and signal tree_exiting. To get notified when the node has already left the active tree, connect to the tree_exited.
fn process(&mut self, delta: f64)
fn process(&mut self, delta: f64)
Called on each idle frame, prior to rendering, and after physics ticks have been processed. delta is the time between frames in seconds.
It is only called if processing is enabled for this Node, which is done automatically if this method is overridden, and can be toggled with set_process.
Processing happens in order of [member process_priority], lower priority values are called first. Nodes with the same priority are processed in tree order, or top to bottom as seen in the editor (also known as pre-order traversal).
Corresponds to the NodeNotification::PROCESS notification in on_notification.
Note: This method is only called if the node is present in the scene tree (i.e. if it’s not an orphan).
Note: When the engine is struggling and the frame rate is lowered, delta will increase. When delta is increased, it’s capped at a maximum of [member Engine.time_scale] * [member Engine.max_physics_steps_per_frame] / [member Engine.physics_ticks_per_second]. As a result, accumulated delta may not represent real world time.
Note: When --fixed-fps is enabled or the engine is running in Movie Maker mode (see MovieWriter), process delta will always be the same for every frame, regardless of how much time the frame took to render.
Note: Frame delta may be post-processed by [member OS.delta_smoothing] if this is enabled for the project.
fn physics_process(&mut self, delta: f64)
fn physics_process(&mut self, delta: f64)
Called once on each physics tick, and allows Nodes to synchronize their logic with physics ticks. delta is the logical time between physics ticks in seconds and is equal to [member Engine.time_scale] / [member Engine.physics_ticks_per_second].
It is only called if physics processing is enabled for this Node, which is done automatically if this method is overridden, and can be toggled with set_physics_process.
Processing happens in order of [member process_physics_priority], lower priority values are called first. Nodes with the same priority are processed in tree order, or top to bottom as seen in the editor (also known as pre-order traversal).
Corresponds to the NodeNotification::PHYSICS_PROCESS notification in on_notification.
Note: This method is only called if the node is present in the scene tree (i.e. if it’s not an orphan).
Note: Accumulated delta may diverge from real world seconds.
fn input(&mut self, event: Gd<InputEvent>)
fn input(&mut self, event: Gd<InputEvent>)
Called when there is an input event. The input event propagates up through the node tree until a node consumes it.
It is only called if input processing is enabled, which is done automatically if this method is overridden, and can be toggled with set_process_input.
To consume the input event and stop it propagating further to other nodes, set_input_as_handled can be called.
For gameplay input, unhandled_input and unhandled_key_input are usually a better fit as they allow the GUI to intercept the events first.
Note: This method is only called if the node is present in the scene tree (i.e. if it’s not an orphan).
fn shortcut_input(&mut self, event: Gd<InputEvent>)
fn shortcut_input(&mut self, event: Gd<InputEvent>)
Called when an InputEventKey, InputEventShortcut, or InputEventJoypadButton hasn’t been consumed by input or any GUI Control item. It is called before unhandled_key_input and unhandled_input. The input event propagates up through the node tree until a node consumes it.
It is only called if shortcut processing is enabled, which is done automatically if this method is overridden, and can be toggled with set_process_shortcut_input.
To consume the input event and stop it propagating further to other nodes, set_input_as_handled can be called.
This method can be used to handle shortcuts. For generic GUI events, use input instead. Gameplay events should usually be handled with either unhandled_input or unhandled_key_input.
Note: This method is only called if the node is present in the scene tree (i.e. if it’s not orphan).
fn unhandled_key_input(&mut self, event: Gd<InputEvent>)
fn unhandled_key_input(&mut self, event: Gd<InputEvent>)
Called when an InputEventKey hasn’t been consumed by input or any GUI Control item. It is called after shortcut_input but before unhandled_input. The input event propagates up through the node tree until a node consumes it.
It is only called if unhandled key input processing is enabled, which is done automatically if this method is overridden, and can be toggled with set_process_unhandled_key_input.
To consume the input event and stop it propagating further to other nodes, set_input_as_handled can be called.
This method can be used to handle Unicode character input with Alt, Alt + Ctrl, and Alt + Shift modifiers, after shortcuts were handled.
For gameplay input, this and unhandled_input are usually a better fit than input, as GUI events should be handled first. This method also performs better than unhandled_input, since unrelated events such as InputEventMouseMotion are automatically filtered. For shortcuts, consider using shortcut_input instead.
Note: This method is only called if the node is present in the scene tree (i.e. if it’s not an orphan).
fn unhandled_input(&mut self, event: Gd<InputEvent>)
fn unhandled_input(&mut self, event: Gd<InputEvent>)
Called when an InputEvent hasn’t been consumed by input or any GUI Control item. It is called after shortcut_input and after unhandled_key_input. The input event propagates up through the node tree until a node consumes it.
It is only called if unhandled input processing is enabled, which is done automatically if this method is overridden, and can be toggled with set_process_unhandled_input.
To consume the input event and stop it propagating further to other nodes, set_input_as_handled can be called.
For gameplay input, this method is usually a better fit than input, as GUI events need a higher priority. For keyboard shortcuts, consider using shortcut_input instead, as it is called before this method. Finally, to handle keyboard events, consider using unhandled_key_input for performance reasons.
Note: This method is only called if the node is present in the scene tree (i.e. if it’s not an orphan).
fn on_notification(&mut self, what: ControlNotification)
fn on_notification(&mut self, what: ControlNotification)
Called when the object receives a Godot notification.
The type of notification can be identified through what. The enum is designed to hold all possible NOTIFICATION_*
constants that the current class can handle. However, this is not validated in Godot, so an enum variant Unknown exists
to represent integers out of known constants (mistakes or future additions).
This method is named _notification in Godot, but on_notification in Rust. To send notifications, use the
Object::notify method.
See also in Godot docs:
fn on_get(&self, property: StringName) -> Option<Variant>
fn on_get(&self, property: StringName) -> Option<Variant>
Called whenever get() is called or Godot gets the value of a property.
Should return the given property’s value as Some(value), or None if the property should be handled normally.
See also in Godot docs:
fn on_set(&mut self, property: StringName, value: Variant) -> bool
fn on_set(&mut self, property: StringName, value: Variant) -> bool
Called whenever Godot set() is called or Godot sets the value of a property.
Should set property to the given value and return true, or return false to indicate the property
should be handled normally.
See also in Godot docs:
fn on_validate_property(&self, property: &mut PropertyInfo)
fn on_validate_property(&self, property: &mut PropertyInfo)
Called whenever Godot retrieves value of property. Allows to customize existing properties.
Every property info goes through this method, except properties added with on_get_property_list().
Exposed property here is a shared mutable reference obtained (and returned to) from Godot.
See also in the Godot docs:
fn on_get_property_list(&mut self) -> Vec<PropertyInfo>
Available on since_api=4.3 only.
fn on_get_property_list(&mut self) -> Vec<PropertyInfo>
since_api=4.3 only.Called whenever Godot get_property_list() is called, the returned vector here is
appended to the existing list of properties.
This should mainly be used for advanced purposes, such as dynamically updating the property list in the editor.
See also in Godot docs:
fn on_property_get_revert(&self, property: StringName) -> Option<Variant>
fn on_property_get_revert(&self, property: StringName) -> Option<Variant>
Called by Godot to tell if a property has a custom revert or not.
Return None for no custom revert, and return Some(value) to specify the custom revert.
This is a combination of Godot’s Object::_property_get_revert and Object::_property_can_revert. This means that this
function will usually be called twice by Godot to find the revert.
Note that this should be a pure function. That is, it should always return the same value for a property as long as self
remains unchanged. Otherwise, this may lead to unexpected (safe) behavior.
fn to_string(&self) -> GString
fn to_string(&self) -> GString
String representation of the Godot instance.
Override this method to define how the instance is represented as a string.
Used by impl Display for Gd<T>, as well as str() and print() in GDScript.
fn has_point(&self, point: Vector2) -> bool
fn has_point(&self, point: Vector2) -> bool
Virtual method to be implemented by the user. Returns whether the given point is inside this control.
If not overridden, default behavior is checking if the point is within control’s Rect.
Note: If you want to check if a point is inside the control, you can use Rect2(Vector2.ZERO, size).has_point(point).
fn get_minimum_size(&self) -> Vector2
fn get_minimum_size(&self) -> Vector2
Virtual method to be implemented by the user. Returns the minimum size for this control. Alternative to [member custom_minimum_size] for controlling minimum size via code. The actual minimum size will be the max value of these two (in each axis separately).
If not overridden, defaults to Vector2.ZERO.
Note: This method will not be called when the script is attached to a Control node that already overrides its minimum size (e.g. Label, Button, PanelContainer etc.). It can only be used with most basic GUI nodes, like Control, Container, Panel etc.
fn get_tooltip(&self, at_position: Vector2) -> GString
fn get_tooltip(&self, at_position: Vector2) -> GString
Virtual method to be implemented by the user. Returns the tooltip text for the position at_position in control’s local coordinates, which will typically appear when the cursor is resting over this control. See get_tooltip.
Note: If this method returns an empty String and make_custom_tooltip is not overridden, no tooltip is displayed.
fn get_drag_data(&mut self, at_position: Vector2) -> Variant
fn get_drag_data(&mut self, at_position: Vector2) -> Variant
Godot calls this method to get data that can be dragged and dropped onto controls that expect drop data. Returns null if there is no data to drag. Controls that want to receive drop data should implement can_drop_data and drop_data. at_position is local to this control. Drag may be forced with force_drag.
A preview that will follow the mouse that should represent the data can be set with set_drag_preview. A good time to set the preview is in this method.
Note: If the drag was initiated by a keyboard shortcut or accessibility_drag, at_position is set to Vector2.INF, and the currently selected item/text position should be used as the drag position.
func _get_drag_data(position):
var mydata = make_data() # This is your custom method generating the drag data.
set_drag_preview(make_preview(mydata)) # This is your custom method generating the preview of the drag data.
return mydatafn can_drop_data(&self, at_position: Vector2, data: Variant) -> bool
fn can_drop_data(&self, at_position: Vector2, data: Variant) -> bool
Godot calls this method to test if data from a control’s get_drag_data can be dropped at at_position. at_position is local to this control.
This method should only be used to test the data. Process the data in drop_data.
Note: If the drag was initiated by a keyboard shortcut or accessibility_drag, at_position is set to Vector2.INF, and the currently selected item/text position should be used as the drop position.
func _can_drop_data(position, data):
# Check position if it is relevant to you
# Otherwise, just check data
return typeof(data) == TYPE_DICTIONARY and data.has("expected")fn drop_data(&mut self, at_position: Vector2, data: Variant)
fn drop_data(&mut self, at_position: Vector2, data: Variant)
Godot calls this method to pass you the data from a control’s get_drag_data result. Godot first calls can_drop_data to test if data is allowed to drop at at_position where at_position is local to this control.
Note: If the drag was initiated by a keyboard shortcut or accessibility_drag, at_position is set to Vector2.INF, and the currently selected item/text position should be used as the drop position.
func _can_drop_data(position, data):
return typeof(data) == TYPE_DICTIONARY and data.has("color")
func _drop_data(position, data):
var color = data["color"]fn make_custom_tooltip(&self, for_text: GString) -> Option<Gd<Object>>
fn make_custom_tooltip(&self, for_text: GString) -> Option<Gd<Object>>
Virtual method to be implemented by the user. Returns a Control node that should be used as a tooltip instead of the default one. for_text is the return value of get_tooltip.
The returned node must be of type Control or Control-derived. It can have child nodes of any type. It is freed when the tooltip disappears, so make sure you always provide a new instance (if you want to use a pre-existing node from your scene tree, you can duplicate it and pass the duplicated instance). When null or a non-Control node is returned, the default tooltip will be used instead.
The returned node will be added as child to a PopupPanel, so you should only provide the contents of that panel. That PopupPanel can be themed using set_stylebox for the type "TooltipPanel" (see [member tooltip_text] for an example).
Note: The tooltip is shrunk to minimal size. If you want to ensure it’s fully visible, you might want to set its [member custom_minimum_size] to some non-zero value.
Note: The node (and any relevant children) should have their [member CanvasItem.visible] set to true when returned, otherwise, the viewport that instantiates it will not be able to calculate its minimum size reliably.
Note: If overridden, this method is called even if get_tooltip returns an empty string. When this happens with the default tooltip, it is not displayed. To copy this behavior, return null in this method when for_text is empty.
Example: Use a constructed node as a tooltip:
func _make_custom_tooltip(for_text):
var label = Label.new()
label.text = for_text
return labelExample: Use a scene instance as a tooltip:
func _make_custom_tooltip(for_text):
var tooltip = preload("res://some_tooltip_scene.tscn").instantiate()
tooltip.get_node("Label").text = for_text
return tooltipfn accessibility_get_contextual_info(&self) -> GString
fn accessibility_get_contextual_info(&self) -> GString
Return the description of the keyboard shortcuts and other contextual help for this control.
fn get_accessibility_container_name(&self, node: Option<Gd<Node>>) -> GString
fn get_accessibility_container_name(&self, node: Option<Gd<Node>>) -> GString
Override this method to return a human-readable description of the position of the child node in the custom container, added to the [member accessibility_name].
fn gui_input(&mut self, event: Gd<InputEvent>)
fn gui_input(&mut self, event: Gd<InputEvent>)
Virtual method to be implemented by the user. Override this method to handle and accept inputs on UI elements. See also accept_event.
Example: Click on the control to print a message:
func _gui_input(event):
if event is InputEventMouseButton:
if event.button_index == MOUSE_BUTTON_LEFT and event.pressed:
print("I've been clicked D:")If the event inherits InputEventMouse, this method will not be called when:
-
the control’s [member mouse_filter] is set to
MouseFilter::IGNORE; -
the control is obstructed by another control on top, that doesn’t have [member mouse_filter] set to
MouseFilter::IGNORE; -
the control’s parent has [member mouse_filter] set to
MouseFilter::STOPor has accepted the event; -
the control’s parent has [member clip_contents] enabled and the
event’s position is outside the parent’s rectangle; -
the
event’s position is outside the control (seehas_point).
Note: The event’s position is relative to this control’s origin.
fn draw(&mut self)
fn draw(&mut self)
Called when CanvasItem has been requested to redraw (after queue_redraw is called, either manually or by the engine).
Corresponds to the CanvasItemNotification::DRAW notification in on_notification.
fn get_configuration_warnings(&self) -> PackedArray<GString>
fn get_configuration_warnings(&self) -> PackedArray<GString>
The elements in the array returned from this method are displayed as warnings in the Scene dock if the script that overrides it is a tool script.
Returning an empty array produces no warnings.
Call update_configuration_warnings when the warnings need to be updated for this node.
@export var energy = 0:
set(value):
energy = value
update_configuration_warnings()
func _get_configuration_warnings():
if energy < 0:
return ["Energy must be 0 or greater."]
else:
return []fn get_accessibility_configuration_warnings(&self) -> PackedArray<GString>
fn get_accessibility_configuration_warnings(&self) -> PackedArray<GString>
The elements in the array returned from this method are displayed as warnings in the Scene dock if the script that overrides it is a tool script, and accessibility warnings are enabled in the editor settings.
Returning an empty array produces no warnings.
fn get_focused_accessibility_element(&self) -> Rid
fn get_focused_accessibility_element(&self) -> Rid
Called during accessibility information updates to determine the currently focused sub-element, should return a sub-element RID or the value returned by get_accessibility_element.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.