Native Android scroller for Data Grid

╄→гoц情女王★ 提交于 2020-01-15 09:12:56

问题


I'm using the code below for native Adroid scroller for Data Grid and it works almost OK. Almost, because in one particular view in my stack it seems to be unreliable. Download the stack and check the following: Go back and forth 3-4 times clicking between "My Categories" and "My Selection" then at some point the scrolling does not work in the "My Categories" view. I then have to restart the app and it works OK. What do you think it depends on? The code is:

    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 group "DataGrid 1" into tScrollerRect

   // Set the area of the content to be scrolled
  put 0,0,(the DGformattedWidth of group "DataGrid 1"),(the DGformattedHeight of group "DataGrid 1") 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 DGvScroll of group "DataGrid 1" to vOffset
end scrollerDidScroll

You can download the stack here.


回答1:


I downloaded and installed your stack. If I just scroll, all seems to work fine. If I click on My Categories, it doesn't scroll, probably because the contentRect is incorrect. If I click on My Selection, the datagrid is empty and obviously scrolling won't work.

I suggest you execute

put 0,0,(the DGformattedWidth of group "DataGrid 1"),(the DGformattedHeight of group "DataGrid 1") into tContentRect
mobileControlSet "loremScroll", "contentRect", tContentRect

every time when the script of one of the buttons All Categories, My Selection or My Categories runs.



来源:https://stackoverflow.com/questions/22943152/native-android-scroller-for-data-grid

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!