The EventBox
has been deprecated in Gtk4 and EventController
is recommended as its replacement. I have a problem with the usage:
imports.gi.versions.Gtk = "4.0";
const { Gtk, GObject } = imports.gi;
Gtk.init();
var ExampleApp = GObject.registerClass(
class ExampleApp extends Gtk.Application {
vfunc_activate() {
let appWindow = new Gtk.ApplicationWindow({ application: this, });
let add = new Gtk.Box({ halign: Gtk.Align.CENTER });
add.append(new Gtk.Image({ icon_name: 'list-add-symbolic' }));
let ctl = new Gtk.EventControllerLegacy({});
add.add_controller(ctl);
ctl.connect('event', () => { /* do sth. */ });
appWindow.set_child(add);
appWindow.present();
}
});
new ExampleApp().run([imports.system.programInvocationName].concat(ARGV));
I got this when hovering on the box:
(gjs:119912): Gjs-WARNING **: 09:49:20.415: JS ERROR: Error: Failed to convert GValue to a fundamental instance
@2test.js:21:18
What’s the right way to get a widget similar to the EventBox
?