Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

点击button时如何拿到button对应的entity? #2567

Open
alonprince opened this issue Feb 24, 2025 · 1 comment
Open

点击button时如何拿到button对应的entity? #2567

alonprince opened this issue Feb 24, 2025 · 1 comment
Labels
question Further information is requested

Comments

@alonprince
Copy link

button点击时如何获取到点的是哪个button?

bindCardEvent() {
    this.cardGroupEntity.children.forEach((card) => {
      card.getComponent(Button)?.addClicked(this.onCardBtnClick);
    });
  }
private onCardBtnClick(e) {
  console.log(this, e);
}

打印了一下this和e,好像没办法直接用
Image

@cptbtptpbcptdtptp
Copy link
Collaborator

在 1.5 里程碑我们会:

  • 在 PointerEventData 中加入更多的信息,可以让开发者分辨是哪个节点触发(即使是使用同个 onClick 回调)
  • 以及为 Button 添加 clear 所有 click 回调等高频操作的函数
    现在可能需要开发者自行为每个 button 设置特定的点击回调临时解决了。

@GuoLei1990 GuoLei1990 added the question Further information is requested label Feb 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants