【问题标题】:flash builder(flex): VScrollbar for a DataGroup, how to scroll down by default?flash builder(flex): DataGroup 的 VScrollbar,默认如何向下滚动?
【发布时间】:2010-01-23 17:49:11
【问题描述】:

我有一个 HGroup,其中包含一个 DataGroup 和一个用于 dataProvider 的 ArrayCollection。

DataGroup 附加了一个 VScrollBar。

如何确保每当向 ArrayCollection 添加新行时,dataGroup 都会向下滚动?

此窗口将用于聊天应用程序,因此每当添加新行时,我都需要查看新行。

我知道我可以执行以下命令来向下滚动:chatScrollBar.value=chatScrollbar.maximum

但是每当新行可见时,我需要附加什么事件才能运行此命令?

<s:HGroup width="100%">
 <s:DataGroup id="vertView"  
     clipAndEnableScrolling="true" width="100%" height="60"
     dataProvider="{chatMessages}">

  <s:itemRenderer>
   <fx:Component>
    <s:ItemRenderer width="100%" height="8">
     <s:states>
      <s:State name="normal" />
      <s:State name="hovered" />
     </s:states>

     <s:RichText  text="{ data }" textAlign="left" paddingLeft="2" color="black" color.hovered="blue"/>
    </s:ItemRenderer>
   </fx:Component>
  </s:itemRenderer>

  <s:layout> 
   <s:VerticalLayout useVirtualLayout="true"/> 
  </s:layout> 
 </s:DataGroup> 
 <s:VScrollBar id="chatScrollBar" viewport="{vertView}" 
      height="{vertView.height}" />

</s:HGroup>

【问题讨论】:

    标签: apache-flex flex4 flash-builder


    【解决方案1】:

    你必须设置verticalScrollPosition。请参阅herehere。或者试试这个作为 Spark 列表:

    <s:List id="list"
                horizontalCenter="0"
                verticalCenter="0">
            <s:layout>
                <s:VerticalLayout id="vLayout" requestedRowCount="4"
                        verticalScrollPosition="{vLayout.maxScrollPosition}" />
            </s:layout>
    </s:list>
    

    【讨论】:

    • 不幸的是 valueCommit 不会在我添加一行时被执行,我尝试使用 s:List 而不是 s:DataGroup 但我得到了相同的结果
    • VerticalLayout 没有 maxScrollPosition
    • 啊,你是对的。只有FB4在工作。当您尝试 chatScrollBar.maxScrollPosition 时?明天上班自己试试。
    • 目前我没有 chatScrollBar,因为我移到了一个列表。如果我们能找到 List 的解决方案,我会更愿意。感谢您的所有帮助
    • 我明天去找 :-)
    【解决方案2】:

    尝试使用Scroller,我认为它很简单:

    <s:Scroller >
      <s:HGroup>
      ...
      </s:HGroup>
    </s:Scroller>
    

    您不需要连接自己的滚动条。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-11-08
      • 2014-02-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-10-22
      • 1970-01-01
      相关资源
      最近更新 更多