www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - gtkD: events being triggered twice

reply Johnson Jones <JJ Dynomite.com> writes:
GtkEventBox - Enter
GtkEventBox - Enter
Down
GtkEventBox - Leave
Up
GtkEventBox - Leave
GtkEventBox - Leave

That is when I move the mouse over the event box then click then 
move out out then release.

I would expect

Enter Down Leave Up

The fact that enter and leave are not paired equally is a 
problem. Can be worked around but seems like it would be a bug.

the code is simply


ebox.addOnEnterNotify(delegate(Event e, Widget w)
{	
writeln(w.getName(), " - ", "Enter");
return true;									});

ebox.addOnLeaveNotify((Event e, Widget w)
{									writeln(w.getName(), " - ", "Leave");
return true;
});
Aug 05
parent reply Mike Wey <mike-wey example.com> writes:
On 06-08-17 03:25, Johnson Jones wrote:
 GtkEventBox - Enter
 GtkEventBox - Enter
 Down
 GtkEventBox - Leave
 Up
 GtkEventBox - Leave
 GtkEventBox - Leave
 
 That is when I move the mouse over the event box then click then move 
 out out then release.
 
 I would expect
 
 Enter Down Leave Up
 
 The fact that enter and leave are not paired equally is a problem. Can 
 be worked around but seems like it would be a bug.
 
 the code is simply
 
 
 ebox.addOnEnterNotify(delegate(Event e, Widget w)
 {
 writeln(w.getName(), " - ", "Enter");
 return true;                                    });
 
 ebox.addOnLeaveNotify((Event e, Widget w)
 {                                    writeln(w.getName(), " - ", "Leave");
 return true;
 });
Do you have an more complete example that i could test. -- Mike Wey
Aug 06
parent reply FoxyBrown <Foxy Brown.IPT> writes:
On Sunday, 6 August 2017 at 09:42:03 UTC, Mike Wey wrote:
 On 06-08-17 03:25, Johnson Jones wrote:
 GtkEventBox - Enter
 GtkEventBox - Enter
 Down
 GtkEventBox - Leave
 Up
 GtkEventBox - Leave
 GtkEventBox - Leave
 
 That is when I move the mouse over the event box then click 
 then move out out then release.
 
 I would expect
 
 Enter Down Leave Up
 
 The fact that enter and leave are not paired equally is a 
 problem. Can be worked around but seems like it would be a bug.
 
 the code is simply
 
 
 ebox.addOnEnterNotify(delegate(Event e, Widget w)
 {
 writeln(w.getName(), " - ", "Enter");
 return true;                                    });
 
 ebox.addOnLeaveNotify((Event e, Widget w)
 {                                    writeln(w.getName(), " - 
 ", "Leave");
 return true;
 });
Do you have an more complete example that i could test.
I don't really(my code is a bit more complex) but basically all it boils down to is a UI with some nested widgets (an overlay, an box, and a box and one contains the eventbox which I added those callbacks on. I think that something like https://github.com/gtkd-developers/GtkD/blob/master/demos/gtkD/TestWindow/TestWindow.d should probably work by just adding an eventbox somewhere and adding that code above. If it doesn't exhibit the same behavior then it has something to do with my project and I could try to reduce it to a minimal example.
Aug 06
parent reply Mike Wey <mike-wey example.com> writes:
On 06-08-17 16:58, FoxyBrown wrote:
 I don't really(my code is a bit more complex) but basically all it boils 
 down to is a UI with some nested widgets (an overlay, an box, and a box 
 and one contains the eventbox which I added those callbacks on.
 
 I think that something like
 
 https://github.com/gtkd-developers/GtkD/blob/master/demos/gtkD/Tes
Window/TestWindow.d 
 
 
 should probably work by just adding an eventbox somewhere and adding 
 that code above.
 
 If it doesn't exhibit the same behavior then it has something to do with 
 my project and I could try to reduce it to a minimal example.
To test i put the label that is on the label page in an event box but that doesn't reproduce the issue. I get just a single event on enter and a single event on leave. -- Mike Wey
Aug 06
parent reply FoxyBrown <Foxy Brown.IPT> writes:
On Sunday, 6 August 2017 at 18:26:20 UTC, Mike Wey wrote:
 On 06-08-17 16:58, FoxyBrown wrote:
 I don't really(my code is a bit more complex) but basically 
 all it boils down to is a UI with some nested widgets (an 
 overlay, an box, and a box and one contains the eventbox which 
 I added those callbacks on.
 
 I think that something like
 
 https://github.com/gtkd-developers/GtkD/blob/master/demos/gtkD/TestWindow/TestWindow.d
 
 
 should probably work by just adding an eventbox somewhere and 
 adding that code above.
 
 If it doesn't exhibit the same behavior then it has something 
 to do with my project and I could try to reduce it to a 
 minimal example.
To test i put the label that is on the label page in an event box but that doesn't reproduce the issue. I get just a single event on enter and a single event on leave.
Ok, I will try to work on figuring out what is going and and potentially reduce to a test case. It might be on my end. I'm pretty sure I'm not adding You might try a separator though in the event box and might try to add it handling various events(maybe even other events for the event box)... things related to the mouse. Here's the glade code for the event box I'm using <object class="GtkEventBox" id="MainSeparator"> <property name="height_request">5</property> <property name="visible">True</property> <property name="can_focus">False</property> <property name="above_child">True</property> <child> <object class="GtkSeparator"> <property name="height_request">5</property> <property name="visible">True</property> <property name="sensitive">False</property> <property name="can_focus">False</property> <property name="events"/> <property name="orientation">vertical</property> </object> </child> </object> Try that when you get some time and see if that changes anything. If it doesn't then it's surely in my code or in the gtk version I'm using(still using msys, I'll update to what you released to see if that fixes it). At least we can narrow it down a little...
Aug 06
next sibling parent reply Adam D. Ruppe <destructionator gmail.com> writes:
On Sunday, 6 August 2017 at 19:27:15 UTC, FoxyBrown wrote:
                 <child>
                   <object class="GtkSeparator">
I don't know gtk, but I would suspect moving the mouse over the child triggers the enter/leave notifications too and it bubbles up to the parent.
Aug 07
parent Johnson Jones <JJ Dynomite.com> writes:
On Monday, 7 August 2017 at 16:13:18 UTC, Adam D. Ruppe wrote:
 On Sunday, 6 August 2017 at 19:27:15 UTC, FoxyBrown wrote:
                 <child>
                   <object class="GtkSeparator">
I don't know gtk, but I would suspect moving the mouse over the child triggers the enter/leave notifications too and it bubbles up to the parent.
Yeah, but both those events are from EventBox. If that were true I'd except Separator to be shown as the widget that has the event. I do return true from the handler which I believe is suppose to stop any more handlers. Although, it does sound something like what you are saying... but it also doesn't explain why the events are not paired, which is the more serious issue.
Aug 07
prev sibling parent reply Mike Wey <mike-wey example.com> writes:
On 06-08-17 21:27, FoxyBrown wrote:
 On Sunday, 6 August 2017 at 18:26:20 UTC, Mike Wey wrote:
 On 06-08-17 16:58, FoxyBrown wrote:
 I don't really(my code is a bit more complex) but basically all it 
 boils down to is a UI with some nested widgets (an overlay, an box, 
 and a box and one contains the eventbox which I added those callbacks 
 on.

 I think that something like

 https://github.com/gtkd-developers/GtkD/blob/master/demos/gtkD/Tes
Window/TestWindow.d 



 should probably work by just adding an eventbox somewhere and adding 
 that code above.

 If it doesn't exhibit the same behavior then it has something to do 
 with my project and I could try to reduce it to a minimal example.
To test i put the label that is on the label page in an event box but that doesn't reproduce the issue. I get just a single event on enter and a single event on leave.
Ok, I will try to work on figuring out what is going and and potentially reduce to a test case. It might be on my end. I'm pretty sure I'm not adding You might try a separator though in the event box and might try to add it handling various events(maybe even other events for the event box)... things related to the mouse. Here's the glade code for the event box I'm using <object class="GtkEventBox" id="MainSeparator"> <property name="height_request">5</property> <property name="visible">True</property> <property name="can_focus">False</property> <property name="above_child">True</property> <child> <object class="GtkSeparator"> <property name="height_request">5</property> <property name="visible">True</property> <property name="sensitive">False</property> <property name="can_focus">False</property> <property name="events"/> <property name="orientation">vertical</property> </object> </child> </object> Try that when you get some time and see if that changes anything. If it doesn't then it's surely in my code or in the gtk version I'm using(still using msys, I'll update to what you released to see if that fixes it). At least we can narrow it down a little...
Also seems to be working properly with a Separator. -- Mike Wey
Aug 07
parent Johnson Jones <JJ Dynomite.com> writes:
On Monday, 7 August 2017 at 21:01:33 UTC, Mike Wey wrote:
 On 06-08-17 21:27, FoxyBrown wrote:
 [...]
Also seems to be working properly with a Separator.
Ok, I guess it's on my end, I don't see how since I'm not doing a hell of a lot and only gtk is calling those event handlers, I'll try to create a test app at some point. I've already added logic to prevent multiple reentries though so, for now I've solved the problem.
Aug 07