Scrolling Group with native scrolling multiline input

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
nicoloose
Posts: 99
Joined: Mon Sep 16, 2013 3:35 pm

Scrolling Group with native scrolling multiline input

Post by nicoloose » Mon Apr 08, 2019 5:29 pm

My app retrieves data from a DB and displays to the user. I am having trouble with the scrolling part. I have been staring at this code for too long to figure it out. Can someone help. Effectively, I want to create a native scrolling group and within that group, create a native multiline input.

Code: Select all

on preOpenCard
   if the environment is "mobile" then
      
      set the top of grp "ContentGroup" to the top of grp "scrollingGroup"
      set the vScroll of grp "scrollingGroup" to 0
      set the layerMode of grp "contentGroup" to "dynamic"
      createTheScroller
   end if
   ## Get the data from dialogData
   put the dialogData into tData
   split tData with cr and colon
   put tData["ug_ID"] into tID
   put tData["ug_name"] into tName
   set the title of widget "Header Bar" of this card to tName
   pass preOpenCard
end preOpenCard
Then on openCard

Code: Select all

on openCard
   //put empty into field "guideDescription"
   ## Find the steps and stepsimg tables and gather all the info for the userGuide ID passed
   put "steps_ugID = :1" into theParamsA["conditions"]
   put tID into theParamsA["condition bindings"][1]
   put "steps_ID ASC" into theParamsA["order by"]
   sqlrecord_find "steps", theParamsA, sStepsA
   if sStepsA is not empty then
      put sStepsA[1] into sOriginalRecordA
   end if
   put sOriginalRecordA["steps_name"] into tDescription
   put cr after tDescription
   put sOriginalRecordA["steps_description"] after tDescription
   //set the text of field "guideDescription" to tDescription
   
   ## Create an input field to show the Title
   
   if the environment is "mobile" then
      mobileControlCreate "input", "ugHeader"
      mobileControlSet "ugHeader", "rect", the rect of graphic "ugHeader"
      mobileControlSet "ugHeader", "visible", true
      mobileControlSet "ugHeader", "fontSize", "14"
      mobileControlSet "ugHeader", "textColor", "blue"
      mobileControlSet "ugHeader", "textAlign", "center"
      mobileControlSet "ugHeader", "enabled", false
      mobileControlSet "ugHeader", "text", tName
      
      ## Create a multiLine field to show the description
      
      mobileControlCreate "multiline", "ugDescription"
      mobileControlSet "ugDescription", "rect", the rect of graphic "grScrollingGroup"
      mobileControlSet "ugDescription", "visible", true
      mobileControlSet "ugDescription", "fontSize", "14"
      mobileControlSet "ugDescription", "textColor", "blue"
      mobileControlSet "ugDescription", "textAlign", "left"
      mobileControlSet "ugDescription", "enabled", false
      mobileControlSet "ugDescription", "editable", "false"   
      mobileControlSet "ugDescription", "dataDetectorTypes", "link"
      mobileControlSet "ugDescription", "autoCorrectionType", "no"
      mobileControlSet "ugDescription", "scrollingEnabled", "true"
      mobileControlSet "ugDescription", "opaque", "false"
      mobileControlSet "ugDescription", "text", tDescription
   end if
end openCard
Then the controller code

Code: Select all

command createTheScroller
  local sTopScrollerID, theWidth,theHeight,tDgRect
  
  if environment() is not "mobile" then exit to top
  
  if "theScroller_1" is not among the lines of mobileControls() then
    MobileControlCreate "scroller", "theScroller_1"
    put the result into sTopScrollerID
  end if
  set the unboundedHScroll of grp "scrollingGroup" to false
  set the unboundedVScroll of grp "scrollingGroup" to true 
  
  put the rect of grp "scrollingGroup" into tDgRect

  put the FormattedWidth of grp "ContentGroup" into theWidth
  put the FormattedHeight of grp "ContentGroup" into theHeight
  
  mobileControlSet sTopScrollerID, "hscroll", 0
  mobileControlSet sTopScrollerID, "vscroll", 0
  mobileControlSet sTopScrollerID, "rect", tDgRect
  mobileControlSet sTopScrollerID, "contentRect", (0,0,theWidth,theHeight)
  mobileControlSet sTopScrollerID, "visible", "true"
  mobileControlSet sTopScrollerID, "canBounce", "true"
  mobileControlSet sTopScrollerID, "pagingEnabled", "false"
  mobileControlSet sTopScrollerID, "canScrollToTop", "true"
  mobileControlSet sTopScrollerID, "delayTouches", "true"
  mobileControlSet sTopScrollerID, "canCancelTouches", "false"
  mobileControlSet sTopScrollerID, "declerationRate", "normal"
  mobileControlSet sTopScrollerID, "lockDirection", "true"
  mobileControlSet sTopScrollerID, "scrollingEnabled", "true"
  
  mobileControlSet sTopScrollerID, "hIndicator", "false"
  mobileControlSet sTopScrollerID, "vIndicator", "false"
end createTheScroller

on scrollerDidScroll OffsetX, OffsetY
      set the hScroll of grp "scrollingGroup" to OffsetX
      set the vScroll of grp "scrollingGroup" to OffsetY
end scrollerDidScroll
Everything display, nothing scrolls!

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7237
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Scrolling Group with native scrolling multiline input

Post by jacque » Tue Apr 09, 2019 6:12 pm

I didn't read through all of the scripts but a quick scan looks okay. Am I correct that the only thing in the group is the native input control? Scrollers only work on the topmost layer (the group in this case) , and also, native controls can't be grouped anyway.

If I remember right, multi-line input fields scroll by themselves, so if that's the only thing in the group then you don't need to do much. Don't use a group and just put the text into the input field, and that should be it.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

nicoloose
Posts: 99
Joined: Mon Sep 16, 2013 3:35 pm

Re: Scrolling Group with native scrolling multiline input

Post by nicoloose » Tue Apr 09, 2019 9:33 pm

I will be creating graphics on the fly so the group will contain more than just a native multiline field. I wanted to get the scroller working as a proof of concept first before I get into the nitty gritty of creating the graphics. The graphics are also created dynamically from fields in a DB

Post Reply

Return to “Getting Started with LiveCode - Experienced Developers”