scorninpc / php-gtk3

GTK3 extension for PHP
https://andor.com.br/
GNU Lesser General Public License v3.0
119 stars 13 forks source link

Widget::has_focus return integer #128

Closed d47081 closed 4 months ago

d47081 commented 4 months ago

Widget::has_focus return integer not boolean type https://docs.gtk.org/gtk3/method.Widget.has_focus.html

scorninpc commented 4 months ago

I need working code for that

My code returning boolean too https://github.com/scorninpc/php-gtk3/blob/1f24ea63a15b3f392a850f280d84573b19409582/src/Gtk/GtkWidget.cpp#L1983

scorninpc commented 4 months ago

This is a nice example about i'm talking about d47081

I wrote a code to test your problem, you understand?

<?php

Gtk::init();

$win = new GtkWindow();
$win->set_default_size(300, 200);
$win->connect("destroy", "GtkWindowDestroy");

$button = \GtkButton::new_with_label("OK");
$win->add($button);
$button->connect("clicked", function($button) use ($win) {
    echo "OK\n";

    var_dump($win->has_focus());
    var_dump($button->has_focus());
});

$win->show_all();

Gtk::main();

and just after that i can confirm your problem

image

and now i can search the problem:

image

gboolean are a alias for integer

and now i can help

image

you see all work just to change gboolean to bool?

as a dev, i'm just asking to you help me too :)

btw, the problem fixed

d47081 commented 4 months ago

Just opened your comment, and too late.. it's fixed

I'm not much experienced in cpp (to operate data types there) but in php it may cause errors, so thanks