mouseMove & backgoundBehavior

Richard Gaskin ambassador at fourthworld.com
Thu Apr 27 12:35:52 EDT 2017


Jim Lambert wrote:

 > Make a group that is smaller than your card.
 > Place this in the group’s script:
 > 	on mousemove newMouseH, newMouseV
 > 		put newMouseH, newMouseV
 > 	end mousemove
 >
 > When the cursor moves around within the group the current mouseLoc is
 > put into the message box. When the cursor moves outside of the group
 > the mouseloc is no longer placed into the message box.
 >
 > Next set the backgroundBehaviour of the group to TRUE.
 >
 > Now wherever the cursor is within the CARD the mouseLoc is placed in
 > the message box regardless of whether the cursor is within or without
 > the rect of the group.
 >
 > The dictionary states, "The mouseMove message is sent to the control
 > the mouse pointer is over, or to the card if no control is under the
 > mouse pointer.”
 >
 > It is true that a background group is not 'officially' on a card
 > (rather it’s on the background in HyperCard parlance.) But why would
 > the mousemove message get passed to the card when the mouse is
 > outside of the background group containing that handler?
 >
 > Is this a bug or expected behavior?

You've been working with LiveCode too long, and have forgotten the 
semantic roots of the ancient mother tongue. :)

In HC there was only one background on any given card, it was always 
present, and it filled the card.  All messages passed from the card to 
the background before moving on to the stack.

In LiveCode, groups by default act as controls, and their message 
handling works as you expect, in visual layer order, responding only to 
messages that occur in objects contained within the group.

But when you set the backgroundBehavior of a group to true, you're 
telling LC to act like HC: that group's script then occupies a different 
place in the message path, between the card and the stack, so that it 
can deliver what a ported HyperCard stack would expect.

This becomes clearer if you modify your recipe script:

on mousemove newMouseH, newMouseV
    put the name of the target, newMouseH, newMouseV &cr after message
end mousemove

With that you can observe behavioral differences between moving the 
mouse when the group's backgroundBehavior is true and when that's set to 
false.

When the backgroundBehavior is false, of course the only target is the 
control within the group, and that's the only target identified in the 
list growing in the Message Box.

But when true, you'll see a mix of objects, sometimes the control in the 
group and sometimes the card, depending on whether the mouse is within 
the control.

This becomes even more evident if you modify the recipe script to 
include "me", and pass the message, and then copy that to both the card 
and stack scripts:

on mousemove newMouseH, newMouseV
    put the name of me && the name of the target, newMouseH, newMouseV \
      &cr after message
    pass mouseMove
end mousemove


TL;DR:  Don't go out of your way to use a property designed for 
HyperCard compatibility and you'll remain in the more flexible and 
sometimes more predictable LiveCode paradigms. :)

-- 
  Richard Gaskin
  Fourth World Systems
  Software Design and Development for the Desktop, Mobile, and the Web
  ____________________________________________________________________
  Ambassador at FourthWorld.com                http://www.FourthWorld.com




More information about the use-livecode mailing list