如何在 GEF 中选择儿童人物?

发布于 2024-10-12 08:28:36 字数 566 浏览 2 评论 0原文

我使用逻辑示例作为参考,实现了将端口作为子项添加到矩形图/EditPart/模型中。端口图按预期显示,调试显示 EditPart 和模型已创建并添加到父级,但子级不可选择。

在子项的 EditPart 中,我重写 isSelectable() 以返回 true。

在父级中,我尝试重写 createChildEditPolicy() 以返回 NonRessizedEditPolicy,方法是反转使子项不可选择的建议 此处,但它似乎什么也没做。如果我在子项的 EditPart 中将 NonResizableEditPolicy 作为 SELECTION_FEEDBACK_ROLE 安装,则在创建时最初会选择它,但以后就无法选择它。

此外,当单击子级的图形时,也不会选择父级 - 这是一个死点,单击不会更改选择。

我是否遗漏了一些东西来使其可选择,或者是否有其他东西在干扰?

I implemented adding ports as children to a rectangle Figure/EditPart/Model using the Logic example as a reference. The port Figures display as expected, and debugging shows that the EditParts and Models are created and added to the parent, but the children are not selectable.

In the EditPart for the children, I override isSelectable() to return true.

In the parent I tried overriding createChildEditPolicy() to return NonResizableEditPolicy, by reversing the recommendation for making children not selectable here, but it appears to do nothing. If I install NonResizableEditPolicy as a SELECTION_FEEDBACK_ROLE in the child's EditPart, it is initially selected upon creation, but then cannot be selected later.

Also, when the child's Figure is clicked, the parent is not selected either - it is a dead spot where clicking does not change selection.

Am I missing something to make it selectable, or is it likely something else is interfering?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

缱倦旧时光 2024-10-19 08:28:36

您可以尝试使用调试器为查看器 getEditPartAt(Point) 设置断点,并从那里单步执行。当您单击子项时,应该会触发此操作。

可能只是没有创建任何选择反馈,因此您也可以尝试输出viewer.getSelectedEditParts()来检查选择是否实际存在,但缺少反馈。

You can try with debugger to set breakpoint to viewers getEditPartAt(Point) and stepping from there where it goes. This should be triggered when you click on the child.

It might be that there just isn't any selection feedbacks created, so you can also try outputting the viewer.getSelectedEditParts() to check that is the selection actually there, but the feedback missing.

情绪失控 2024-10-19 08:28:36

我遇到了同样的问题,并以如下方式修复它:尝试在编辑部分安装合适的策略。

   @Override
   protected void createEditPolicies() {
       installEditPolicy(EditPolicy.LAYOUT_ROLE, yourEditPolicy());
   }

I meet the same issue , and fix it in the way : try to install a suitable policy in the editpart.

   @Override
   protected void createEditPolicies() {
       installEditPolicy(EditPolicy.LAYOUT_ROLE, yourEditPolicy());
   }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文