Initial 'stab' to get constrainRectangularCallback going

Create fast, sprite powered games with Animation Engine, co-developed with DerBrill Software!

Moderators: heatherlaine, kevinmiller, robinmiller, malte

Post Reply
dave.kilroy
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 858
Joined: Wed Jun 24, 2009 1:17 pm
Location: Plymouth, UK
Contact:

Initial 'stab' to get constrainRectangularCallback going

Post by dave.kilroy » Wed Jul 18, 2012 5:52 pm

Hi all

I've created a slider using Obelo's slider tutorial/script.

For iOS, on the simulator (I'm using LC 5.5.1 on Lion on a Mac) everything works fine. On a device (iPhone 4 running 5.1.1) there is an initial delay in getting the slider to do anything. It needs a bit of a 'stab' on the slider button to get it working, after that it works fine and the user can slide the slider side-to-side nice and smooth.

The 'stab' it needs is not really huge, but there is no 'stab' needed to get the 'unlock' slider moving on iOS and i should think an average user would think the app was broken because ordinare pressure and sliding action does not get the slider moving.

I haven't tried this on an Android device yet (and I want it working properly on Android as well as iOS). has anyone experienced anything similar?


This is the script of the slider 'thumb' image:

Code: Select all

on constrainRectangularInit
   set the constrainRectangular of graphic "grc_blueFill" to the rect of graphic "grc_blueFill"--of graphic "grc_scrollerConstain"
   set the constrainRectangular of graphic "grc_Thumb2" to the rect of graphic "grc_scrollerConstain"
end constrainRectangularInit
    

on constrainRectangularExit
   switch the short name of the current card
      case "cdDuration"
         put sConvertNum into gDuration
         break
      case "cdInterest"
         put sConvertNum into gInterest
         break
   end switch
end constrainRectangularExit
    
    
on constrainRectangularCallback
   get distance(the loc of grc "grc_lineStart1", the loc of grc "grc_Thumb2")
   put it into tConvertNum
   
   # use this to move the fill
   put (tConvertNum + 20) into tFillMove
   set the width of graphic "grc_blueFill" to tFillMove
   set the left of graphic "grc_blueFill" to the left of graphic "grc_scrollerConstain"
   
   if the short name of this card is "cdDuration" then
      put (tConvertNum / 2) into tConvertNum -- removed this line for this version of example
      multiply tConvertNum by (gDuration2 / 100)
      put round (tConvertNum) into tConvertNum
      if tConvertNum < gDuration1 then put gDuration1 into tConvertNum
      if tConvertNum > 1 then
         put tConvertNum & " " & gPeriodTypePlural into field "fld_Return2"
      else
         put tConvertNum & " " & gPeriodTypeSingular into field "fld_Return2"
      end if
      
   else--if the short name of this card is "cdInterest"
      put tConvertNum into tMinCheck     
      put gInterest2 - gInterest1 into tSpan
      multiply tConvertNum by (tSpan / 100)
      multiply tConvertNum by 0.5
      put round (tConvertNum) into tConvertNum
      add gInterest1 to tConvertNum
      if tConvertNum < gInterest1 then put gInterest1 into tConvertNum
      if tMinCheck = 1 then put gInterest1 into tConvertNum
      put tConvertNum & "% APR"  into field "fld_Return2"
   end if
   
   put tConvertNum into sConvertNum
   put tFillMove into gBlueFillLength
end constrainRectangularCallback
The collection of slider images are in a background group which is shared by two cards. I was using it previously not in a group and the initial 'stab' was exactly the same. I am using AnimationEngine 5.02 and I have remembered to 'start using' it in the preOpenStack

Any ideas as to what I'm doing wrong or have forgotten to do?
"...this is not the code you are looking for..."

malte
Posts: 1098
Joined: Thu Feb 23, 2006 8:34 pm
Location: Ostenfeld germany
Contact:

Re: Initial 'stab' to get constrainRectangularCallback going

Post by malte » Mon Jul 23, 2012 9:41 pm

Hey Dave,

please excuse the late reply. I am again travelling a lot these days. :-)

I do not see anything wrong with your script, besides the constrainRectangular not being set initially perhaps.
Before you test in the simulator or device (maybe right after start using) you could set the constrainRectangular property of the object you want to move.

Hope that helps,

Malte

dave.kilroy
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 858
Joined: Wed Jun 24, 2009 1:17 pm
Location: Plymouth, UK
Contact:

Re: Initial 'stab' to get constrainRectangularCallback going

Post by dave.kilroy » Fri Jul 27, 2012 3:02 pm

Hi Malte

Thanks for the reply, I too am responding late

Thanks also for suggestion about constrainRectangularInit but I send a message to do this from the card's openCard script (see below)

Code: Select all

on openCard
   send constrainRectangularInit to graphic "grc_Thumb2" in 20 milliseconds
   send constrainRectangularCallback to graphic "grc_Thumb2" in 20 milliseconds
   --   send constrainRectangularExit to graphic "grc_Thumb2" in 0 seconds
   pass openCard
end openCard
The reason I do this is I found if I set it in the constrainRectangularCallback handler that on the device if a user clicked on the graphic to the right of "grc_Thumb2" that the image would disappear and things would start going bad. I did try it with it in the normal place but I found no difference (initial 'stab' still needed + everything went haywire if I clicked on the graphic to the right of "grc_Thumb2"

Any suggestions? Maybe something about timing or something? or am I missing something else?

Kind regards
"...this is not the code you are looking for..."

dave.kilroy
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 858
Joined: Wed Jun 24, 2009 1:17 pm
Location: Plymouth, UK
Contact:

Re: Initial 'stab' to get constrainRectangularCallback going

Post by dave.kilroy » Mon Jul 30, 2012 6:00 pm

OK think I've found out what is going on...

Basically, I have fat fingers (probably fairly average for a guy though) and what was happening is that on an iPhone 4 the 'thumb' graphic of the slider was too small. I was too lazy to change it from Obelo's script where he had it at 22x22 pixels (which is fine for a mouse - and also fine on a simulator) but on an iPhone's screen it's too small and needs an initial 'stab' (with my fat fingers at least) to get it going.

The Apple HIG says controls should be around 40x40 (can't remember exact size) so I doubled Obelo's graphic to 44x44 and it worked v nice on my iPhone (looked horrible though but that's another issue for another day).

So, I hope this is of use to others taking controls designed for desktop to mobile - size matters!

Kind regards

Dave
"...this is not the code you are looking for..."

malte
Posts: 1098
Joined: Thu Feb 23, 2006 8:34 pm
Location: Ostenfeld germany
Contact:

Re: Initial 'stab' to get constrainRectangularCallback going

Post by malte » Tue Jul 31, 2012 5:55 am

Thanks for posting that Dave!

Wouldn't have thought of that.

All the best,


Malte

Post Reply

Return to “Animation Engine”