Sign up

Mouse coordinates and Focus issues cause paned not to work

I have some strange code but after refactoring everything seems to be working as I want, almost.

I'm having 2 issues.

  1. I am getting the position of clicks from the mouse but it seems that the position is relative to the child elements for a paned. This causes position calculations to not be correct as I would like.

e.g., if the upper corner of the parent is 0,0 then the first child is 0,0 and say 100, 100

and then the second is 100,0 and 500,300 but the position returns 0,0 and 400,200

But I'd expect the position to be absolute from the parent itself.

The first time I was doing this I went to the parent to get the absolute coordinates but this time(for a different problem) it is not working.

The issue is that if I want to do something with a click in the range of 100 to 200(the second child) I have no way of knowing if it's in the first or second because it tells me it's 0 to 100 which is the same as the first child.

I tried to add handler on the full parent and it worked except it caused other problems with the Paned Handle event(it basically stopped functioning as normal so I reverted to the above issue since it should be easier to fix).

I'm going to try to play around with translating coordinates and see if I figure out what is going on. The paned contains a box and it seems that it's given me the coordinates with respect to the boxes even though I'm using the paned's click handler(so I'd expect the coords to be with respect to the paned and have nothing to do with the boxes).

  1. In my paned I have some text entries in some children... when they are in edit mode(they have focus) the paned's handle no longer moves, at lead in some conditions which I haven't figured out.

One of the problems is the way I'm doing some things where I let clicking on the item to do other things... but using a modifier... and essentially both handlers get called. e.g., if I use ctrl and click the entry still get's focus I could probably override the handlers and avoid this possibly but I'd have to do it for each handler. I'll probably have to do this to get everything working in the end but I'll then still have my paned not work if the entries have focus.

I might just make them not editable but it would reduce functionality.

To be clear, the issue here is two fold:

a. When a descendant gtkEntry has "focus"(it was clicked on and can take keyboard text), the gtkPaned that contains it's handle no longer works(can't reposition) at least some of the time. When other stuff is clicked the entry stays in edit mode and I can move the handle ones then can't move it again unless I click somewhere else.

b. When a modifier key is held the gtkEntry is clicked on and gets "focus". I only want a click or double click to enable editing without any modifier.

I figure can probably get the behavior to work by handling a lot of events but I'm hoping there is a better way.

Re: Mouse coordinates and Focus issues cause paned not to work

On 12-06-2019 09:15, Alex X wrote:

I have some strange code but after refactoring everything seems to be working as I want, almost.

I'm having 2 issues.

  1. I am getting the position of clicks from the mouse but it seems that the position is relative to the child elements for a paned. This causes position calculations to not be correct as I would like.

The coordinates should usually be relative to the widget that receives
the signal.

gdk.Window.coordsFromParent()
gdk.Window.coordsToParent()

Can be useful if you need the coordinates relative to the parent.

  1. In my paned I have some text entries in some children... when they are in edit mode(they have focus) the paned's handle no longer moves, at lead in some conditions which I haven't figured out.

One of the problems is the way I'm doing some things where I let clicking on the item to do other things... but using a modifier... and essentially both handlers get called. e.g., if I use ctrl and click the entry still get's focus I could probably override the handlers and avoid this possibly but I'd have to do it for each handler. I'll probably have to do this to get everything working in the end but I'll then still have my paned not work if the entries have focus.

Maybe one of the signal handlers is returning true instead of false
stopping gtk from preforming the default behavior for the event?

Re: Mouse coordinates and Focus issues cause paned not to work

On Wed, 12 Jun 2019 23:09:21 +0200, Mike Wey wrote:

On 12-06-2019 09:15, Alex X wrote:

I have some strange code but after refactoring everything seems to be working as I want, almost.

I'm having 2 issues.

  1. I am getting the position of clicks from the mouse but it seems that the position is relative to the child elements for a paned. This causes position calculations to not be correct as I would like.

The coordinates should usually be relative to the widget that receives
the signal.

gdk.Window.coordsFromParent()
gdk.Window.coordsToParent()

Can be useful if you need the coordinates relative to the parent.

Ok, this might work. I'm specifically overriding the paned and not the box so I'm doing this in the parent(since I refactored my code) but maybe I can use those above to get things to work.

  1. In my paned I have some text entries in some children... when they are in edit mode(they have focus) the paned's handle no longer moves, at lead in some conditions which I haven't figured out.

One of the problems is the way I'm doing some things where I let clicking on the item to do other things... but using a modifier... and essentially both handlers get called. e.g., if I use ctrl and click the entry still get's focus I could probably override the handlers and avoid this possibly but I'd have to do it for each handler. I'll probably have to do this to get everything working in the end but I'll then still have my paned not work if the entries have focus.

Maybe one of the signal handlers is returning true instead of false
stopping gtk from preforming the default behavior for the event?

Yeah, but that would have to be one of the gtkEntry's, which when they are focused they are causing the problem? I'm not messing with any of those...

I guess I'll just have to do some troubleshooting to find out ...

Thanks.