How to select lines in a field under a scroller in IOS

Mark Talluto userev at canelasoftware.com
Tue Mar 19 18:25:44 EDT 2013


On Mar 19, 2013, at 2:27 PM, Michael Doub <mikedoub at gmail.com> wrote:

> Devin, you are correct.   I have a LiveCode field wrapped in an IOS scroller.   I have been playing with various list behavior and autohilite properties.   Since I am trying to select multiple lines at the same time I am seeing a conflict between the behavior of the field and the scroller.
> 
> Looking at the behaviour of the native input control,  apple seems to use a double tap to get into a select mode.  They seem to turn off the scroll while the selection is taking place then turn it back on again.  
> 
> It seems that I need to figure out how to disable scrolling during the selection process and then enable it again.
> 
> -= Mike


Here is some code that I use for my scrolling fields.  I can determine if you are clicking or scrolling.  It will also give you a tap to end of field (opposite of Apples tap at top of screen to quick scroll to top feature).


on ____LC_MESSAGES
end ____LC_MESSAGES
on preOpenCard
     put false into gWeAreScrollingFlag
    
     if the environment is "mobile" then
          set the traversalOn of fld "search" of card gSettingsA["search"] of stack gSettingsA["mainStack"] to false
          set the lockText of fld "search" of card gSettingsA["search"] of stack gSettingsA["mainStack"] to true
          set the doubleClickDelta to 100
          set the vScrollBar of fld "users" to false
     else
          set the doubleClickDelta to 4
          click at the loc of fld "find"
          set the vScrollBar of fld "users" to true
     end if
     
     if gSettingsA["hiliteColor"] <> empty then set the hiliteColor of fld "users" to gSettingsA["hiliteColor"] else set the hiliteColor of fld "users" to 255,114,0     
end preOpenCard



command csGetDatabaseFirstTime    
     --DOWNLOAD THE DATABASE ON FIRST RUN
     if gFirstRun then
          set the vis of fld "users" to false
          
          flashInternetIndicatorOff the short name of this card,the short name of this stack
          put false into gFirstRun
          
          if the environment is "mobile" then
               --KEYBOARD
               mobileSetKeyboardType "default"
               set the acceleratedRendering of this stack to true
               iphoneUseDeviceResolution false
               
               --CREATE SCROLLER FOR FIELD USERS IF NEEDED
               put mobileControls() into tControlList
               if "Users Scroller" is not in tControlList then
                    send "csSetupMobileScroller" && "users","gUsers" to me in 10 ticks
               end if
          end if
          
          set the vis of fld "users" to true
     end if
end csGetDatabaseFirstTime



on csTraversalOn
     set the traversalOn of fld "search" of card gSettingsA["search"] of stack gSettingsA["mainStack"] to true
end csTraversalOn



on ____CREATE_SCROLLER
end ____CREATE_SCROLLER
on csSetupMobileScroller pField,pGroup
     if the environment <> "mobile" then exit csSetupMobileScroller
     
     --SET UP THE USERS FIELD AND DATABASE GROUP
     lock screen
     set the vScroll of group pGroup to 0
     set the vScroll of fld pField to 0
     
     set the vis of fld pField to true
     set the listbehavior of field pField to true
     put the formattedHeight of field pField into tHeight
     put the width of field pField into tWidth
     
     --GIVE FIELD EXTRA SPACE SO WE CAN BOUNCE FIELD WITH LESS THAN A FULL SCREEN OF TEXT
     put the height of grp pGroup into tDatabaseHeight
     if tHeight < tDatabaseHeight + 10 then
          put true into tShortField
          set the height of field pField to tDatabaseHeight + 1
     else
          --DO NORMAL SPACING
          set the height of fld pField to tHeight
     end if
     
     put the height of fld pField into tHeight
     put the top of group pGroup into tDatabaseTop
     set the top of fld pField to 65
     
     put the rect of group pGroup into tRect
     set the unboundedvScroll of group pGroup to true
     
     --CREATE SCROLLER
     mobileControlCreate "scroller","Users Scroller"
     put the result into gUsersScrollerId
     mobileControlSet gUsersScrollerId,"rect",tRect
     
     mobileControlSet gUsersScrollerId,"contentRect",(0,0,tWidth,tHeight)
     
     mobileControlSet gUsersScrollerId,"visible","true"
     mobileControlSet gUsersScrollerId,"canBounce",true
     
     mobileControlSet gUsersScrollerId,"declerationRate",fast
     mobileControlSet gUsersScrollerId,"scrollingEnabled",true
     mobileControlSet gUsersScrollerId,"canScrollToTop",true
     mobileControlSet gUsersScrollerId,"delayTouches",false
     mobileControlSet gUsersScrollerId,"canCancelTouches",true
     
     mobileControlSet gUsersScrollerId,"hIndicator",false
     mobileControlSet gUsersScrollerId,"vIndicator",true
     
     mobileControlSet gUsersScrollerId,"indicatorInsets","0,0,5,0"
     mobileControlSet gUsersScrollerId,"vScroll",0
     mobileControlSet gUsersScrollerId,"hScroll",0
     
     
     --SCROLL TO THE END OF THE FIELD
     --IF THE FIELD IS FULL OF TEXT
     if not tShortField then
          put the height of fld pField into tUserHeight
          put the height of grp pGroup into tDatabaseHeight
          
          put tUserHeight - tDatabaseHeight into tDiff
          
          set the vScroll of group pGroup to tDiff
          mobileControlSet gUsersScrollerId,"vScroll",tDiff
     end if
     
     unlock screen
end csSetupMobileScroller




on ____SCROLLER_MESSAGES
end ____SCROLLER_MESSAGES
on scrollerDidScroll pOffsetX,pOffsetY
     put true into gWeAreScrollingFlag
     lock screen
     set the vScroll of group "gUsers" to pOffsetY
     mobileControlSet gUsersScrollerId,"vScroll",pOffsetY
     unlock screen
end scrollerDidScroll


on scrollerBeginDrag
     set the autohilite of fld "users" to false
     set the hilitedLine of fld "users" to empty
     put true into gWeAreScrollingFlag
end scrollerBeginDrag


on scrollerEndDrag
     put false into gWeAreScrollingFlag
end scrollerEndDrag


on scrollerEndDecelerate
     set the autohilite of fld "users" to true
     put false into gWeAreScrollingFlag
end scrollerEndDecelerate






More information about the use-livecode mailing list