У меня есть sparkContainer, который содержит текстовый ввод Spark.У меня есть обработчики событий mouse_down и mouse_up на borderContainer, чтобы перетаскивать его по экрану;при перетаскивании я изменяю курсор.
Я бы хотел, чтобы textInput вел себя как «стандартный» textInput, т.е. при нажатии на textInput пользователь не должен иметь возможность перетаскивать весь компонент, а просто взаимодействовать с текстомкак он / она будет обычно.Кроме того, я хотел бы, чтобы курсор textInput выглядел как обычный курсор textInput.
Я не уверен, что делаю это правильно.Я предполагаю, что мне нужно остановить распространение mouse_down и mouse_up на textInput, чтобы запретить поведение перетаскивания от его родителя, и управлять rollOver и rollOut, чтобы курсор выглядел нормально.Ниже приведен пример моего кода (чтобы упростить его, нет borderContainer или перетаскивания - но код для этого был бы очень простым - чуть длиннее).
Так вот в чем проблема: если щелкнуть искрой textInput, а затем развернуть его, курсор превратится в комбинацию курсора textInput + стандартный курсор, установленный для borderContainer.Похоже, этого не происходит с компонентами mx textInput (то есть с двумя полями), но, к сожалению, мне нужно использовать компоненты spark.Я предполагаю, что я либо неправильно вызываю cursorManager, либо я не останавливаю распространение mouse_up должным образом - кажется, что он должен поразить textInput, но не распространяться на borderContainer.Я тоже попробовал stopPropagation (), но не повезло.
Буду рад любому совету / конструктивной критике.
спасибо!
f
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600"
creationComplete="application1_creationCompleteHandler(event)"
mouseDown="application1_mouseDownHandler(event)"
mouseUp="application1_mouseUpHandler(event)">
<fx:Script>
<![CDATA[
import mx.events.FlexEvent;
import mx.managers.CursorManager;
[Bindable] [Embed(source="../resources/hand.png")] private var _handIcon:Class;
[Bindable] [Embed(source="../resources/Fist.png")] private var _fistIcon:Class;
private var _cursorID:int;
protected function textinput1_rollOutHandler(e:MouseEvent):void
{
e.stopImmediatePropagation();
CursorManager.removeCursor(_cursorID);
_cursorID = CursorManager.setCursor(_handIcon);
}
protected function textinput1_rollOverHandler(e:MouseEvent):void
{
e.stopImmediatePropagation();
CursorManager.removeCursor(_cursorID);
}
protected function application1_creationCompleteHandler(e:FlexEvent):void
{
_cursorID = CursorManager.setCursor(_handIcon);
}
private function stopPropagation(event:MouseEvent):void
{
event.preventDefault();
event.stopImmediatePropagation();
}
protected function textinput1_mouseDownHandler(event:MouseEvent):void
{
stopPropagation(event);
}
protected function textinput1_mouseUpHandler(event:MouseEvent):void
{
stopPropagation(event);
}
protected function application1_mouseDownHandler(event:MouseEvent):void
{
CursorManager.removeCursor(_cursorID);
_cursorID = CursorManager.setCursor(_fistIcon);
}
protected function application1_mouseUpHandler(event:MouseEvent):void
{
CursorManager.removeCursor(_cursorID);
_cursorID = CursorManager.setCursor(_handIcon);
}
]]>
</fx:Script>
<s:TextInput x="43" y="30"
rollOut="textinput1_rollOutHandler(event)"
rollOver="textinput1_rollOverHandler(event)"
mouseDown="textinput1_mouseDownHandler(event)"
mouseUp="textinput1_mouseUpHandler(event)"/>
<mx:TextInput x="43" y="70"
rollOut="textinput1_rollOutHandler(event)"
rollOver="textinput1_rollOverHandler(event)"
mouseDown="textinput1_mouseDownHandler(event)"
mouseUp="textinput1_mouseUpHandler(event)"/>