Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AssertionError: Object of type AspectFrame does not fullfill the widget interface #71

Open
LilithHafner opened this issue Feb 3, 2024 · 3 comments · May be fixed by #75
Open

AssertionError: Object of type AspectFrame does not fullfill the widget interface #71

LilithHafner opened this issue Feb 3, 2024 · 3 comments · May be fixed by #75
Labels
Acknowledged We are aware of this issue and will respond soon

Comments

@LilithHafner
Copy link
Contributor

When I try to use an AspectFrame (or any other widget I've tried) for the signal_connect_motion! signal handler, I get an AssertionError: Object of type AspectFrame does not fullfill the widget interface error. I'm assuming that Mousetrap.AspectFrame is supposed to fulfill the widget interface.

julia> using Mousetrap

julia> main() do app::Application
           window = Window(app)

           aspect_frame = AspectFrame(1.0)

           set_child!(window, aspect_frame)

           connect_signal_motion!(aspect_frame) do _, x, y
               println((x,y))
           end

           present!(window)
       end

(<unknown>:128894): GLib-GObject-CRITICAL **: 14:55:44.274: g_object_unref: assertion 'G_IS_OBJECT (object)' failed
[ERROR] In Mousetrap.main: AssertionError: Object of type AspectFrame does not fullfill the widget interface. In order for it to be able to be treated as a widget, you need to subtype `Mousetrap.Widget` **and** add a method with signature `(::AspectFrame) -> Widget` to `Mousetrap.get_top_level_widget`, which should map an instance of AspectFrame to its top-level widget component.
Stacktrace:
 [1] macro expansion
   @ ~/.julia/packages/Mousetrap/WZu6w/src/Mousetrap.jl:0 [inlined]
 [2] get_top_level_widget(x::AspectFrame)
   @ Mousetrap ~/.julia/packages/Mousetrap/WZu6w/src/Mousetrap.jl:362
 [3] connect_signal_motion!(f::Function, x::AspectFrame)
   @ Mousetrap ~/.julia/packages/Mousetrap/WZu6w/src/Mousetrap.jl:5530
 [4] (::var"#16#18")(app::Application)
   @ Main ./REPL[2]:8
 [5] (::TypedFunction)(args::Application)
   @ Mousetrap ~/.julia/packages/Mousetrap/WZu6w/src/Mousetrap.jl:91
 [6] (::Mousetrap.var"#14#15"{TypedFunction})(app::Application)
   @ Mousetrap ~/.julia/packages/Mousetrap/WZu6w/src/Mousetrap.jl:1542
 [7] (::TypedFunction)(args::Application)
   @ Mousetrap ~/.julia/packages/Mousetrap/WZu6w/src/Mousetrap.jl:91
 [8] (::Mousetrap.var"#6#8"{TypedFunction})(x::Tuple{CxxWrap.CxxWrapCore.CxxRef{Mousetrap.detail._Application}})
   @ Mousetrap ~/.julia/packages/Mousetrap/WZu6w/src/Mousetrap.jl:657
 [9] safe_call(scope::String, f::Function, args::Tuple{CxxWrap.CxxWrapCore.CxxRef{Mousetrap.detail._Application}})
   @ Mousetrap ~/.julia/packages/Mousetrap/WZu6w/src/Mousetrap.jl:190
0
@Clemapfel Clemapfel added the Acknowledged We are aware of this issue and will respond soon label Feb 8, 2024
@Clemapfel
Copy link
Owner

Clemapfel commented Feb 8, 2024

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

@Clemapfel
Copy link
Owner

That said, that error message doesn't make any sense, I will keep this open until the message is replaced with something more descriptive.

@Clemapfel Clemapfel linked a pull request Feb 8, 2024 that will close this issue
@Clemapfel
Copy link
Owner

Clemapfel commented Feb 8, 2024

Fixed by 4f16e9f, 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Acknowledged We are aware of this issue and will respond soon
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants