【问题标题】:Spark DataGrid on mobile application handle scroll and selection item移动应用程序上的 Spark DataGrid 处理滚动和选择项
【发布时间】:2012-01-21 05:36:46
【问题描述】:

我在移动应用程序上有一个 spark 数据网格,我设置了

interactionMode="touch"

dataGrid 滚动很好,我在添加selectionChange eventListener 时遇到了一些问题,因为滚动 dataGrid 会自动更改选择,而不是简单地滚动它,绑定的函数将启动...

如何在选择索引之前添加触摸日期,所以如果我滚动网格,选择不会改变,只有当我按下项目而不滚动时才会改变?

【问题讨论】:

    标签: apache-flex mobile datagrid event-handling flex-spark


    【解决方案1】:

    我使用了一种解决方法....

    我使用mouseUpmouseDown 来检查单击和释放之间的时间,而不是添加selectionChange 事件监听器,如果释放时间小于单击加上一些时间,则返回选择,否则不返回。 ..

    <s:DataGrid id="grigliaData"
       sortableColumns="false"
       rowHeight="100"
       interactionMode="touch"
       mouseDown="grigliaData_mouseDownHandler(event)"
       mouseUp="grigliaData_mouseUpHandler(event)"
       top="230" left="5" right="5" bottom="50"
       dataProvider="{listaEventi}" width="100%" height="100%"> 
    
      //AS Code 
            private var _lastClickEvent:int;
            protected function grigliaData_mouseDownHandler(event:MouseEvent):void
            {
                _lastClickEvent = getTimer();
            }
    
            protected function grigliaData_mouseUpHandler(event:MouseEvent):void
            {
                if (getTimer() < _lastClickEvent + 200) // 200 = Dalay
                {
                                   // return selectedIndex
                }
            }
    

    编辑: 我还添加了对 mouseX 和 mouseY 位置的检查,如果释放前的时间和位置的变化小于默认的 dalay(时间/像素),现在网格会调度 selectionChange...

    【讨论】:

    • 它可以工作,除非单击启用排序的数据网格中的列标题。为了解决这个问题,我使用了 gridMouseDown 和 gridMouseUp 而不是 mouseDown 和 mouseUp。
    • 感谢您的评论...后来我遇到了同样的问题...我解决了更改 mouseUpHandler 中的 if 并添加 selectedIndex > -1 和 != null :) :)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-09-09
    • 2011-11-26
    • 2015-01-08
    • 1970-01-01
    • 1970-01-01
    • 2021-03-01
    • 1970-01-01
    相关资源
    最近更新 更多