php-gtk3
php-gtk3 copied to clipboard
fix GdkEvent, GdkEventButton, GdkEventKey properties initiation #106
Solution for GDK warnings (#106)
can you provide a simple code with the problem?
This issue happens on:
- keypress on entry
- button click event
Common GdkEvent (that implements GdkEventButton, GdkEventKey) also drop warnings for type, key, button.
Deprecated: Creation of dynamic property GdkEventButton::$type is deprecated in /home/i/Apps/yggverse/Yoda/src/Yoda.php on line 39
Deprecated: Creation of dynamic property GdkEventButton::$send_event is deprecated in /i/ibox/Apps/yggverse/Yoda/src/Yoda.php on line 39
Deprecated: Creation of dynamic property GdkEventButton::$time is deprecated in /home/i/Apps/yggverse/Yoda/src/Yoda.php on line 39
Deprecated: Creation of dynamic property GdkEventButton::$x is deprecated in /home/i/Apps/yggverse/Yoda/src/Yoda.php on line 39
Deprecated: Creation of dynamic property GdkEventButton::$y is deprecated in /home/i/Apps/yggverse/Yoda/src/Yoda.php on line 39
...
This solution resolve the problem using nullable properties initiation on __construct. Resulting event dump in testing application looks well (as designed)
$entry->connect(
'key-release-event',
function (
\GtkEntry $entry,
\GdkEvent $event
) {
var_dump($event);
}
);
object(GdkEvent)#71 (3) {
["type"]=>
int(9)
["button"]=>
object(GdkEventButton)#72 (10) {
["type"]=>
int(9)
["send_event"]=>
int(0)
["time"]=>
int(4611196)
["x"]=>
int(0)
["y"]=>
int(0)
["axes"]=>
bool(true)
["state"]=>
int(41)
["button"]=>
int(0)
["x_root"]=>
float(0)
["y_root"]=>
float(0)
}
["key"]=>
object(GdkEventKey)#73 (11) {
["type"]=>
int(9)
["send_event"]=>
int(0)
["time"]=>
int(4611196)
["state"]=>
int(16)
["keyval"]=>
int(102)
["length"]=>
int(1)
["string"]=>
bool(true)
["hardware_keycode"]=>
int(41)
["keycode"]=>
int(41)
["group"]=>
int(0)
["is_modifier"]=>
int(0)
}
}