On 01/01/2019 20:39, Alex Tweedly via use-livecode wrote:

However - I'm not sure that's a very intuitive UI ("release to play"), so I'd probably go the extra mile and do the harder one that replicates the original UI. And that *is* harder, so I will try it out before I say any more about it ...

OK, here's a simple script that does what (I think) you want.

NB - I decided to let Malte do the hard work and used AnimationEngine to check whether the mouse was within each hexagon; since Malte very generously put AE into the public domain, I see no reason to struggle through the maths again :-)

The following script goes into the card script; you MUST also put a copy of the mouseStillDown handler into each hexagon's script. (Note there is no actual dependence on them being hexagons).

-- card script for hexagons
on mouseDown
   setCurrentHex
end mouseDown

on mouseUp
   setCurrentHex
end mouseUp

on mouseRelease
  setCurrentHex
end mouseRelease

on mouseStillDown pButtonNumber
  setcurrentHex
end mouseStillDown

command setcurrentHex
   local temp, tCtl, txy, x, y
   put the mouseLoc into txy
   set the itemdel to comma
   put item 1 of tXY into x
   put item 2 of txy into y
   repeat with i = 1 to 2
      put the points of grc ("P"&i) into temp
      if  pointInPoly(x,y,temp) then
         put i && the millisecs &CR after msg
         exit repeat
      end if
   end repeat
end setcurrentHex

btw - you can eliminate the mouseDown, mouseUp and mouseRelease handlers, if you can accept the very short delay until mouseStillDown kicks in.

Alex.

_______________________________________________
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Reply via email to