Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
25
Task/Mouse-position/Vala/mouse-position.vala
Normal file
25
Task/Mouse-position/Vala/mouse-position.vala
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
// GTK 4
|
||||
public class Example : Gtk.Application {
|
||||
public Example() {
|
||||
Object(application_id: "my.application",
|
||||
flags: ApplicationFlags.FLAGS_NONE);
|
||||
activate.connect(() => {
|
||||
var window = new Gtk.ApplicationWindow(this);
|
||||
var box = new Gtk.Box(Gtk.Orientation.VERTICAL, 20);
|
||||
var button = new Gtk.Button.with_label("Get Cursor Position");
|
||||
button.clicked.connect((a) => {
|
||||
double x, y;
|
||||
var device_pointer= window.get_display().get_default_seat().get_pointer();
|
||||
window.get_surface().get_device_position(device_pointer, out x, out y, null);
|
||||
label.set_text(x.to_string() + "," + y.to_string());
|
||||
});
|
||||
box.append(label);
|
||||
box.append(button);
|
||||
window.set_child(box);
|
||||
window.present();
|
||||
});
|
||||
}
|
||||
public static int main(string[] argv) {
|
||||
return new Example().run(argv);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue