【问题标题】:Selecting id of TextArea (despite RichEditableText)选择 TextArea 的 id(尽管 RichEditableText)
【发布时间】:2010-06-17 02:27:32
【问题描述】:

我正在尝试选择一个 textArea 的 id,当它被聚焦时

<s:TextArea id="textarea1" focusIn="selectId(event)" />

selectId(event){
   event.target.id;
}

问题是TextAreaRichEditableText 组成,所以target 实际上并不指代TextArea。我已经尝试过event.target.parent.id,但仍然没有到达那里。任何人都知道如何解决这个问题?

【问题讨论】:

  • 你试过 event.currentTarget.id 了吗?
  • 就是这样,如果您发布它,我会接受作为答案。请注意,在使用 event.target 进行一些测试后,它也可以工作,但必须在中间添加 4 个 parent。不知道为什么,我想这就是从RichEditableTextTextArea 需要多少时间
  • @Robusto 你为什么不把它作为答案发布。 @duder event.target 将是被点击的最里面的项目 - 在按钮上,它可以是显示标签的文本字段或蒙皮组件等。不要在这里依赖它,因为它不一定总是 4 个步骤;可能会因您点击的位置而异。

标签: apache-flex actionscript-3 adobe mxml


【解决方案1】:

应@Amargosh 的要求,我将其发布为答案。试试:

event.currentTarget.id

【讨论】:

    【解决方案2】:
    <s:TextArea id="textarea1" focusIn="selectId(event,this.textarea1)" />
    
    private function selectId(event, item) : void
    {
       // Your code to do stuff with item
    }
    

    事实上,如果你不打算使用它,你根本不需要发送事件参数:

    <s:TextArea id="textarea1" focusIn="selectId(this.textarea1)" />
    
    private function selectId(item) : void
    {
       // Your code to do stuff with item
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-12-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-06-11
      • 1970-01-01
      • 2017-04-05
      相关资源
      最近更新 更多