You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While save_dialog() and open_dialog work fine when called from the command line, they break when called by a button.
using GtkObservables, Gtk4
c = canvas(UserUnit)
win = GtkWindow(c)
function saveme(window)
@show "saving"
name = save_dialog("Choose file", window)
@show name
end
savebutton = button("save"; widget=nothing, observable=nothing)
sbox = GtkBox(:v)
push!(sbox, savebutton)
push!(win, sbox) #this is a stupid location to put this button
GtkObservables.gc_preserve(win, savebutton)
savesignal = on(savebutton) do _
@show "click"
saveme(win);
end
When you use the dialog functions in a callback you have to use the method that takes a function callback (or the do syntax). This should probably be more prominent in the documentation:
using GtkObservables, Gtk4
c = canvas(UserUnit)
win = GtkWindow(c)
function saveme(window)
@show "saving"
save_dialog("Choose file", window) do name
@show name
end
end
savebutton = button("save"; widget=nothing, observable=nothing)
sbox = GtkBox(:v)
push!(sbox, savebutton)
push!(win, sbox) #this is a stupid location to put this button
GtkObservables.gc_preserve(win, savebutton)
savesignal = on(savebutton) do _
@show "click"
saveme(win);
end
While save_dialog() and open_dialog work fine when called from the command line, they break when called by a button.
After clicking:
The text was updated successfully, but these errors were encountered: