6

在 Flex 中,默认情况下,当您将鼠标悬停在 Text Input 上时,鼠标光标会变为标准的 I 横杆。如何更改此光标以显示常规鼠标指针光标而不是 I 十字条?

更新:好吧,根据这篇博文,在 Flex 4 中这个过程似乎很简单:http: //blog.flexexamples.com/2008/11/03/setting-mouse-cursors-in-flash-player-10/

由于我暂时坚持使用 Flex 3,我该如何做类似的事情?

更新2:此外,这个问题有点类似于这个问题: 避免光标更改在Flash CS3中的动态文本字段上

不过,我使用的是标准的 Flex Builder,而不是 Flash CS3。

4

5 回答 5

7

澄清一下 -在 Flash 10 上的 Flex 3 中也存在MouseCursorMouse类。因此您可以挂钩 MOUSE_OVER 和 MOUSE_OUT 事件:

elem.addEventListener(MouseEvent.MOUSE_OVER, function(event:Event):void {
    Mouse.cursor = MouseCursor.BUTTON;
});

elem.addEventListener(MouseEvent.MOUSE_OUT, function(event:Event):void {
    Mouse.cursor = MouseCursor.ARROW;
});
于 2010-10-01T11:34:05.860 回答
4

必须修改三个属性 useHandCursor = true buttonMode = true mouseChildren = false

Leete 更多信息这篇文章http://www.anujgakhar.com/2008/03/27/flex-how-to-display-hand-cursor-on-components/

于 2010-03-30T21:27:51.333 回答
2

您必须使用 CursorManager:

import mx.managers.CursorManager;

protected function textMouseOverHandler(event:Event):void
{
    CursorManager.setCursor(yourCursor, yourPriority, xOffset, yOffset);
    // Rest of your handler
}

protected function textMouseOutHandler(event:Event):void
{
    // be sure to set the cursor back here
}
于 2009-04-22T19:24:38.700 回答
0

您可以使用带标签的 HBOX 而不是 TextInput。当鼠标悬停在标签上时,系统不会改变光标。如果您希望用户可以编辑文本,则需要做更多的工作。

public class MyTextInput extends HBox
{
public function  MyTextInput()
{
   super();
   var label:Label = new Label();
   label.text="some text";
   addChild(label);
   addEventListener(MouseEvent.CLICK, editProperties, true);
}
private function editProperties(event:MouseEvent)
{
  //do something to allow the user to edit the text e.g. PopupManager.createPopup
}
}
于 2009-05-13T16:59:22.290 回答
-1

还有另一种方法是为您希望的任何组件将buttonMode属性设置为true。这带来了鼠标光标而不是文本光标。

于 2009-09-16T10:22:48.757 回答