GestureClick::pressed returning negative value, expected?

When I put a GtkWidget derived widget themed as a button in a GtkFixed widget (at position x=100, y=100)
and add a GestureClick controller and attach a “pressed” signal handler to it,
clicking in the top left corner returns x=-7 and y=-2.

Using a GtkButton, instead (with errounously, I suppose, two GestureClick controllers) it returns x=-14 and y=-5.

Considering the documentation reads “The X coordinate, in widget allocation coordinates”,
this seems rather unexpected to me. I’d expect the top left corner to be x=0 and y=0.

Is there something I missed?

I’m running Windows 10 with e8f70be2c1c0532666941db9049cdb7307633e13.

Yes, the documentation is misleading and should be updated. It seems that the coordinates are relative to the widget’s CSS box origin. In the case of button there is some CSS padding around, which I think is why you’re getting negative coordinates.

Could you open a Merge Request in Merge requests · GNOME / gtk · GitLab?

Thanks!
Luca

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.