2012-01-11 23 views
1

我正在使用flex項目,並且有一個datagrid,我希望在將鼠標懸停在包含數據的任何行上時更改光標。在datagrid行上更改光標

我在數據網格上雙擊啓用,我想指出使用它們可以單擊它們徘徊在上面的行。

這是我所嘗試過的,但它似乎只是在datagrid上使用手形光標而不是行數據。

<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> 

回答

0

結束使用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)); 
    } 
    } 
} 
0

我會創造一個itemRenderer並添加事件偵聽器爲MouseEvent.ROLL_OVERMouseEvent.ROLL_OUT事件。在事件處理程序中,您可以使用cursorManager更改光標。這還有一個額外的好處,即允許您根據用戶將光標懸停在其上的行的某些數據或條件來更改光標。

Here's an example在將鼠標懸停在組件上時更改光標。希望這會讓你開始朝正確的方向發展。