【问题标题】:Change cursor on datagrid row更改数据网格行上的光标
【发布时间】:2012-02-08 05:35:33
【问题描述】:

我正在开发一个 flex 项目,并且有一个数据网格,当鼠标悬停在任何包含数据的行上时,我希望光标改变。

我在数据网格上启用了双击功能,我想向用户表明他们可以点击他们悬停的行。

这是我尝试过的,但它似乎只是在数据网格上使用手形光标而不是行数据。

    <mx:DataGrid x="9" y="47" width="330" height="244" useHandCursor="true" buttonMode="true" mouseChildren="true" horizontalScrollPolicy="{ScrollPolicy.AUTO}" styleName="resultgrid" dataProvider="{acLatest}" doubleClickEnabled="true" itemDoubleClick="doubleClickoverview()"  id="overviewLatest_dg">
     <mx:columns>                   
        <mx:DataGridColumn headerText="Tag" id="overviewLatest_dg_animal_ptag" visible="true" dataField="animal_ptag" width="110" />
        <mx:DataGridColumn headerText="Status" id="overviewLatest_dg_status_status" visible="true" dataField="status_status" width="110"/>
        <mx:DataGridColumn headerText="Sex" id="overviewLatest_dg_animal_sex" visible="true" dataField="animal_sex" width="110"/>
     </mx:columns>
    </mx:DataGrid>

【问题讨论】:

    标签: actionscript-3 apache-flex datagrid cursor


    【解决方案1】:

    最终在数据网格上使用 itemRollOver 和 itemRollOut。

    然后创建了一个简单的类,将光标更改为手形图像。

    数据网格:

    itemRollOver="Cursors.setHandCursor()" itemRollOut="CursorManager.removeAllCursors()"
    

    游标类:

    package com {
    
      import mx.managers.CursorManager;
      import mx.managers.CursorManagerPriority;
    
      public class Cursors extends CursorManager {
    
        private static var handCursorList:Array = [];
    
        public static function setHandCursor():void {   
          [Embed(source="../images/hand.png")]   
          var handCursorClass:Class;
          handCursorList.push(setCursor(handCursorClass, CursorManagerPriority.MEDIUM));
        }  
      } 
    }
    

    【讨论】:

      【解决方案2】:

      我会创建一个itemRenderer 并为MouseEvent.ROLL_OVERMouseEvent.ROLL_OUT 事件添加事件侦听器。在事件处理程序中,您可以使用cursorManager 更改光标。这还有一个额外的好处,就是允许您根据用户将光标悬停在的行的某些数据或条件更改光标。

      Here's an example 在将鼠标悬停在组件上时更改光标。希望这能让您朝着正确的方向开始。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2017-03-24
        • 1970-01-01
        • 2014-09-27
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多