Struct Signal
pub struct Signal { /* private fields */ }
Expand description
A Signal
represents a signal of an Object instance in Godot.
Signals are composed of a reference to an Object
and the name of the signal on this object.
§Godot docs
Implementations§
§impl Signal
impl Signal
pub fn from_object_signal<T, S>(object: &Gd<T>, signal_name: S) -> Signal
pub fn from_object_signal<T, S>(object: &Gd<T>, signal_name: S) -> Signal
Create a signal for the signal object::signal_name
.
Godot equivalent: Signal(Object object, StringName signal)
pub fn invalid() -> Signal
pub fn invalid() -> Signal
Creates an invalid/empty signal that cannot be called.
Godot equivalent: Signal()
pub fn connect(&self, callable: Callable, flags: i64) -> Error
pub fn connect(&self, callable: Callable, flags: i64) -> Error
Connects this signal to the specified callable.
Optional flags can be also added to configure the connection’s behavior (see ConnectFlags
constants).
You can provide additional arguments to the connected callable by using Callable::bind
.
A signal can only be connected once to the same Callable
. If the signal is already connected,
returns Error::ERR_INVALID_PARAMETER
and
pushes an error message, unless the signal is connected with ConnectFlags::REFERENCE_COUNTED
.
To prevent this, use Self::is_connected
first to check for existing connections.
pub fn disconnect(&self, callable: Callable)
pub fn disconnect(&self, callable: Callable)
Disconnects this signal from the specified Callable
.
If the connection does not exist, generates an error. Use Self::is_connected
to make sure that the connection exists.
pub fn emit(&self, varargs: &[Variant])
pub fn emit(&self, varargs: &[Variant])
Emits this signal.
All Callables connected to this signal will be triggered.
pub fn connections(&self) -> Array<Dictionary>
pub fn connections(&self) -> Array<Dictionary>
Returns an Array
of connections for this signal.
Each connection is represented as a Dictionary that contains three entries:
signal
is a reference to thisSignal
;callable
is a reference to the connectedCallable
;flags
is a combination ofConnectFlags
.
Godot equivalent: get_connections
pub fn name(&self) -> StringName
pub fn name(&self) -> StringName
Returns the name of the signal.
pub fn object(&self) -> Option<Gd<Object>>
pub fn object(&self) -> Option<Gd<Object>>
Returns the object to which this signal belongs.
Returns None
when this signal doesn’t have any object.
Godot equivalent: get_object
pub fn object_id(&self) -> Option<InstanceId>
pub fn object_id(&self) -> Option<InstanceId>
Returns the ID of this signal’s object, see also Gd::instance_id
.
Returns None
when this signal doesn’t have any object.
Godot equivalent: get_object_id
pub fn is_connected(&self, callable: Callable) -> bool
pub fn is_connected(&self, callable: Callable) -> bool
Returns true
if the specified Callable
is connected to this signal.
Trait Implementations§
§impl ArrayElement for Signal
impl ArrayElement for Signal
fn debug_validate_elements(_array: &Array<Self>) -> Result<(), ConvertError>
§impl FromGodot for Signal
impl FromGodot for Signal
§fn try_from_godot(
via: <Signal as GodotConvert>::Via,
) -> Result<Signal, ConvertError>
fn try_from_godot( via: <Signal as GodotConvert>::Via, ) -> Result<Signal, ConvertError>
Err
on failure.§fn from_godot(via: Self::Via) -> Self
fn from_godot(via: Self::Via) -> Self
§fn try_from_variant(variant: &Variant) -> Result<Self, ConvertError>
fn try_from_variant(variant: &Variant) -> Result<Self, ConvertError>
Variant
, returning Err
on failure.§fn from_variant(variant: &Variant) -> Self
fn from_variant(variant: &Variant) -> Self
§impl ToGodot for Signal
impl ToGodot for Signal
§type ToVia<'v> = <Signal as GodotConvert>::Via
type ToVia<'v> = <Signal as GodotConvert>::Via
to_godot()
, which differs from Via
for pass-by-reference types.§fn to_godot(&self) -> <Signal as ToGodot>::ToVia<'_>
fn to_godot(&self) -> <Signal as ToGodot>::ToVia<'_>
§fn to_variant(&self) -> Variant
fn to_variant(&self) -> Variant
§impl Var for Signal
impl Var for Signal
fn get_property(&self) -> <Signal as GodotConvert>::Via
fn set_property(&mut self, value: <Signal as GodotConvert>::Via)
§fn var_hint() -> PropertyHintInfo
fn var_hint() -> PropertyHintInfo
GodotType::property_info
, e.g. for enums/newtypes.impl GodotType for Signal
Auto Trait Implementations§
impl Freeze for Signal
impl RefUnwindSafe for Signal
impl !Send for Signal
impl !Sync for Signal
impl Unpin for Signal
impl UnwindSafe for Signal
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)