原生机器人滚动3-4个领域在一张卡不工作



我想创建一个有3-4个文本字段的卡片,每个字段都有一个原生的android滚动条。我遵循这里的课程创建一个本机滚动条来滚动字段。我试图使用相同的代码与3个字段,我分组在一起并编码,使该组将有一个本机滚轮另一张卡。每个文本字段都可以通过该卡片上的单独按钮显示。打开应用程序时,滚动不起作用。但是如果我去到同一堆栈中的另一张牌,只是空牌,然后返回到主牌,滚动工作正常。所以在卡片代码中有一些东西我不理解,必须修改,但是什么?

我在卡片中使用这个代码:

    global gScrollField
local sScrollerID
on openCard
   local tScrollerRect, tContentRect
   // Only create a scroller on a mobile device
   if environment() is not "mobile" then exit openCard
   // Set the area of the scroller
   put the rect of gScrollField into tScrollerRect
   // Set the are of the content to be scrolled
   put 0,0,(the formattedWidth of gScrollField),(the formattedHeight of gScrollField) into  tContentRect 
   // Create the scroller control
   mobileControlCreate "scroller", "loremScroll"
   put the result into sScrollerID
   // Set the properties of the scroller
   mobileControlSet "loremScroll", "rect", tScrollerRect
   mobileControlSet "loremScroll", "contentRect", tContentRect
   mobileControlSet "loremScroll", "visible", true
   mobileControlSet "loremScroll", "scrollingEnabled", true
   mobileControlSet "loremScroll", "vIndicator", true
   mobileControlSet "loremScroll", "vscroll", 0
end openCard
on closeCard
   // Delete the scroller
   if environment() is not "mobile" then exit closeCard
   mobileControlDelete sScrollerID
end closeCard
on scrollerDidScroll hOffset, vOffset
   // When the user scrolls move the displayed content
   set the vScroll of gScrollField to vOffset
end scrollerDidScroll
 mouseControl

和在导航按钮中使一个字段可见和隐藏其他字段的代码如下(例如对于卡片"b":

)
    global gScrollField
on mouseUp
   put the long name of fld "b" into gScrollField
   hide fld "a"
   hide fld "c"
   show fld "b"
end mouseUp

到栈的链接是:在同一张卡片上滚动3-4个字段

问题是gScrollField直到a,b,c按钮中的一个被按下才定义:它最初导致preOpenCard处理程序失败。

我将卡片脚本修改为…

    global gScrollField
    local sScrollerID
    local sStarted
    on preOpenCard
       local tScrollerRect, tContentRect
       if sStarted <> true then
          put the long id of fld "a" into gScrollField
          hide fld "c"
          hide fld "b"
          show fld "a"
          put true into sStarted
       end if
       // Only create a scroller on a mobile device
       if environment() is not "mobile" then exit preOpenCard
       .....
       .....
       .....

,它工作正常:)sStarted变量在第一次执行时初始化。

相关内容

最新更新