godot-rust / book

Documentation and tutorials for gdext, the Rust bindings for Godot 4
Mozilla Public License 2.0
18 stars 37 forks source link

Signals chapter contains stale redirect chain regarding `Object::connect()` #61

Open axelmagn opened 3 days ago

axelmagn commented 3 days ago

Section in question: https://godot-rust.github.io/book/register/signals.html?highlight=connect#registering-signals

Specific region:

As an alternative, you can use Godot's dynamic API to register signals. The Object class has methods connect() and emit_signal() that can be used to connect and emit signals, respectively.

While there are quite a few places in the docs that describe how to declare a new signal using #[signal], there does not seem to be anywhere that shows you how to connect a signal to a callable. The link in the above passage to Object::connect() API docs contains the following docstring:

To set the default parameters, use Self::connect_ex and its builder methods. See the book for detailed usage instructions.

This links to the section on functions, which demonstrates how to call a function via Object::call(). However this does not generalize to Object::connect(), which expects a Callable argument rather than the impl AsArg<StringName> expected by Object::call().

I would like to define a function in rust via #[func], then connect it via Object::connect() to a signal. Ideally the book, API docs, or both would include an example of how this could be achieved.

axelmagn commented 3 days ago

marked this as "error" primarily because I found the chain of redirects really confusing.