Open LilithHafner opened 8 months ago
I think you misunderstood the component interface. AspectFrame
, or indeed most widgets, do not support signal motion
. Instead, motion
is a signal of an event controller, EventControllerMotion
in this case. You need to create the event controller, then connect it to a widget using add_controller!
. Afterwards you can connect to the signals of the event controller itself, but it will use the bounds of the widget:
using Mousetrap
main() do app::Application
window = Window(app)
aspect_frame = AspectFrame(1.0)
set_child!(window, aspect_frame)
# create event controller
mouse = MotionEventController()
# connect controller to widget
add_controller!(aspect_frame, mouse)
# connect to signal of controller
connect_signal_motion!(mouse) do _, x, y
println((x,y))
end
present!(window)
end
That said, that error message doesn't make any sense, I will keep this open until the message is replaced with something more descriptive.
Fixed by https://github.com/Clemapfel/Mousetrap.jl/pull/75/commits/4f16e9fbf35728a536fabe323f8fed8cf1bce79f, error message is now:
julia> frame = AspectFrame(1); f = () -> ();
julia> connect_signal_motion!(f, frame)
(process:375474): Mousetrap.jl-CRITICAL **: 18:17:45.974: In emit_signal_motion: object of type `AspectFrame` has no signal with ID `motion`
I'll keep this issue open until #75 is merged
When I try to use an AspectFrame (or any other widget I've tried) for the
signal_connect_motion!
signal handler, I get anAssertionError: Object of type AspectFrame does not fullfill the widget interface
error. I'm assuming that Mousetrap.AspectFrame is supposed to fulfill the widget interface.