TLFTextField 的焦点移出事件
我遇到一个问题,当我在舞台周围单击时,没有调用“FOCUS_OUT”事件。当我单击 TLFTextField 时,我确实收到了“FOCUS_IN”事件。不确定问题是什么,任何提示或想法都会很棒。我已经做了一些谷歌搜索,但没有找到任何有用的东西。
这是我的一些代码:
txt_search.addEventListener(FocusEvent.FOCUS_IN, onFocusIn);
txt_search.addEventListener(FocusEvent.FOCUS_OUT, onFocusOut);
private function onFocusOut(e:FocusEvent):void
{
trace("--Search Field-- :: FocusOut");
if(txt_search.text == '')
{
txt_search.text = _defaultText;
}
else
{
//do nothing
}
}
private function onMouseEvent(e:MouseEvent):void
{
if(txt_search.text != '' && txt_search.text != _defaultText)
{
//do search
trace("--Search Feeds--");
}
else
{
//do nothing
}
}
谢谢!
I'm having an issue where I don't get a "FOCUS_OUT" event called when I click around the stage. I do get the "FOCUS_IN" event when I click the TLFTextField. Not sure what the problem may be, any hints or ideas would be great. I did already do some Google searches, but didnt quite find anything useful.
Here is some of the code I have:
txt_search.addEventListener(FocusEvent.FOCUS_IN, onFocusIn);
txt_search.addEventListener(FocusEvent.FOCUS_OUT, onFocusOut);
private function onFocusOut(e:FocusEvent):void
{
trace("--Search Field-- :: FocusOut");
if(txt_search.text == '')
{
txt_search.text = _defaultText;
}
else
{
//do nothing
}
}
private function onMouseEvent(e:MouseEvent):void
{
if(txt_search.text != '' && txt_search.text != _defaultText)
{
//do search
trace("--Search Feeds--");
}
else
{
//do nothing
}
}
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先,我建议尝试使用所有这四个
然后,您始终可以通过在其他地方添加侦听器来解决焦点事件等事件。例如,如果焦点在一个对象上IN,则意味着它在所有其他对象上OUT。当我写这样的东西时,我有时会使用这个事实。通常,我可以只使用一个事件或另一个事件来逃脱惩罚。您可能不需要两者。
First, I suggest, try playing around with all four of these
Then, you can always work around events like focus events by adding listeners elsewhere. For instance, if the focus is IN on one object, that means it's OUT on all others. I use that fact sometimes when I'm writing things like this. Often, I can get away with using only one event or the other. You may not need both.