I have a group that comprises an image, two buttons and a field. I wish to have the two buttons and field hide when the mouse is not over the group. I have placed mouse enter and leave handlers in the group but have run into a problem. If the mouse happens to be over a control that is made visible it seems that multiple mouse enter messages are triggered. By multiple I mean enough to cause the recurse alert to be posted at a depth of 400000. Often this is enough to crash the IDE.
The dictionary implies that controls below other controls do not receive mouse enter/leave messages. It seems that a group does not "count" as a control from this point of view. I have attached a small stack that can be made to crash by running the mouse in and out through the bottom of the graphic group. Beware that if you try the stack that the visible property of other objects may be set to false when a crash occurs.
I do not understand why so many messages are being generated. I can understand that a message is generated when the mouse enters the group and that a second may be generated if the mouse is over a button or field that is made visible by the first message but where the many thousand other messages come from is a mystery. Is this a feature or is it a bug? Any thoughts?
The stack :
best wishes
Simon K
Multiple MouseEnter messages - crash
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- Posts: 854
- Joined: Wed Nov 04, 2009 11:41 am
- Location: Gunthorpe, North Lincs, UK
Multiple MouseEnter messages - crash
best wishes
Skids
Skids
-
- VIP Livecode Opensource Backer
- Posts: 2718
- Joined: Sat Dec 22, 2007 5:35 pm
- Location: Genève
- Contact:
Re: Multiple MouseEnter messages - crash
Hi Simon,
I played a little with your stack
It seems that adding a condition on mouse leave avoid recursion.
Something like that:
Best regards
Jean-Marc
I played a little with your stack
It seems that adding a condition on mouse leave avoid recursion.
Something like that:
Code: Select all
On MouseLeave
-- add jmb
if the mouseloc is within the rect of group "Picture1" then
exit MouseLeave
end if
-- add jmbEnd
put "mouse Leave" & cr after field "debug" of card 1 of stack "RecursionProblem"
HideControls
end MouseLeave
Jean-Marc
https://alternatic.ch
-
- Posts: 854
- Joined: Wed Nov 04, 2009 11:41 am
- Location: Gunthorpe, North Lincs, UK
Re: Multiple MouseEnter messages - crash
Hi Jean-Marc,
Thanks thats a brilliant solution that solves the problem. I'm impressed that you spotted what was happening as I could not see it at all.
Looking at my original code and your solution I think that the out of control firing of messages occurs so: when the mouse is in the location of one of the hidden controls and that control becomes visible it triggers a mouse-leave message because the mouse has left the background graphic and is now on the button which causes a mouse-enter to also be generated. But the mouse-leave hides the controls causing a new mouse enter message to fire as the mouse has entered the graphic again. This causes the hidden controls to be made visible and the process repeats until the crash occurs.
Thanks again,
best wishes
Simon K
Thanks thats a brilliant solution that solves the problem. I'm impressed that you spotted what was happening as I could not see it at all.
Looking at my original code and your solution I think that the out of control firing of messages occurs so: when the mouse is in the location of one of the hidden controls and that control becomes visible it triggers a mouse-leave message because the mouse has left the background graphic and is now on the button which causes a mouse-enter to also be generated. But the mouse-leave hides the controls causing a new mouse enter message to fire as the mouse has entered the graphic again. This causes the hidden controls to be made visible and the process repeats until the crash occurs.
Thanks again,
best wishes
Simon K
best wishes
Skids
Skids
-
- VIP Livecode Opensource Backer
- Posts: 2718
- Joined: Sat Dec 22, 2007 5:35 pm
- Location: Genève
- Contact:
Re: Multiple MouseEnter messages - crash
But your explanation is better than what I could do in englishI'm impressed that you spotted what was happening as I could not see it at all.
Best
Jean-Marc
https://alternatic.ch
-
- Posts: 854
- Joined: Wed Nov 04, 2009 11:41 am
- Location: Gunthorpe, North Lincs, UK
Re: Multiple MouseEnter messages - crash
Hi Jean-Marc,
I have submitted a suggestion that the documentation be expanded to warn of the problem that I caused and you solved : http://quality.livecode.com/show_bug.cgi?id=20529
Thanks again,
best wishes
Simon
I have submitted a suggestion that the documentation be expanded to warn of the problem that I caused and you solved : http://quality.livecode.com/show_bug.cgi?id=20529
Thanks again,
best wishes
Simon
best wishes
Skids
Skids