如何在 GEF 中选择儿童人物?
我使用逻辑示例作为参考,实现了将端口作为子项添加到矩形图/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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以尝试使用调试器为查看器 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.
我遇到了同样的问题,并以如下方式修复它:尝试在编辑部分安装合适的策略。
I meet the same issue , and fix it in the way : try to install a suitable policy in the editpart.