Mouse messages while down

Mark Powell mark_powell at symantec.com
Sun Mar 18 08:26:28 EDT 2007


Hi Sarah:

Depending on the arrangement and characteristics of your 400 controls,
you could take the approach of putting mouse detection in an image above
your buttons instead of in a card script below:  Create a one-bit
mask...with areas in the image that register with buttons being made
opaque, other areas being transparent.  In Rev set the blendlevel of the
image to 100.  The entire image will be visually transparent, but mouse
clicks will respect *original* opacity/transparency.  Therefore in the
script of the image you could have something like this:

on mouseDown	
  --detectable in opaque areas only	
  put BtnBelowAtMouseDown() into gBtnDown  	
  set the hilite of btn gBtnDown to true	
end mouseDown	
	
on mouseRelease	
  set the hilite of btn gBtnDown to false	
end mouseRelease	

on mouseUp	
  set the hilite of btn gBtnDown to false	
  send mouseUp to btn gBtnDown  -- if needed	
end mouseUp	
	
on mouseMove	
  put BtnBelowAtHover() into tBtnHovered	
  ...	
end mouseMove	


The BtnBelowAtMouseDown and BtnBelowAtHover algorithms depend a lot on
card design.  I have done something similar, but with 4 underlying
controls instead of 400 so I am not sure about performance and the
efficiency of those two algorithms in your particular case.  A
compelling feature of this approach is that the creation of the mask
itself could be scriptable...using snapshot, button rects, alphadata,
etc...though I have never done it.

Mark



More information about the use-livecode mailing list