Multiple MouseEnter messages - crash

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Simon Knight
Posts: 854
Joined: Wed Nov 04, 2009 11:41 am
Location: Gunthorpe, North Lincs, UK

Multiple MouseEnter messages - crash

Post by Simon Knight » Sat Oct 07, 2017 5:04 pm

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 :
RecursionProblem.zip
(18.43 KiB) Downloaded 183 times
best wishes
Simon K
best wishes
Skids

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2718
Joined: Sat Dec 22, 2007 5:35 pm
Location: Genève
Contact:

Re: Multiple MouseEnter messages - crash

Post by jmburnod » Sat Oct 07, 2017 7:21 pm

Hi Simon,
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
Best regards
Jean-Marc
https://alternatic.ch

Simon Knight
Posts: 854
Joined: Wed Nov 04, 2009 11:41 am
Location: Gunthorpe, North Lincs, UK

Re: Multiple MouseEnter messages - crash

Post by Simon Knight » Sat Oct 07, 2017 9:42 pm

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
best wishes
Skids

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2718
Joined: Sat Dec 22, 2007 5:35 pm
Location: Genève
Contact:

Re: Multiple MouseEnter messages - crash

Post by jmburnod » Sun Oct 08, 2017 12:09 am

I'm impressed that you spotted what was happening as I could not see it at all.
But your explanation is better than what I could do in english :D
Best
Jean-Marc
https://alternatic.ch

Simon Knight
Posts: 854
Joined: Wed Nov 04, 2009 11:41 am
Location: Gunthorpe, North Lincs, UK

Re: Multiple MouseEnter messages - crash

Post by Simon Knight » Sun Oct 08, 2017 10:00 am

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
best wishes
Skids

Post Reply

Return to “Getting Started with LiveCode - Experienced Developers”