eclipse的draw2d图形中的文本框
有没有办法在draw2d图形中包含文本框? (代码示例会很好)
Is there any way to include a Text Box inside a draw2d figure? (a code example would be nice)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不容易,如果你只是使用 Draw2d 而没有 GEF,那么我认为这是不可能的。
借助 GEF,您可以在编辑部件中使用
DirectEditManager
,并创建编辑策略(扩展DirectEditPolicy
,使用EditPolicy.DIRECT_EDIT_ROLE
键安装code>) 允许对图形进行直接编辑。您可以创建一个扩展
Label
的图形,其样式看起来像一个文本框,并在选择时激活(通过覆盖编辑部分中的performRequest
)编辑。此架构图示例包含此类功能(更重要的是,代码!),尽管用于编辑的图形 (
EditableLabel
) 的样式看起来不像文本框,并且激活本身是双击而不是选择。不过,它可能会为您指明正确的方向。
Not easily, and if you're just using Draw2d without GEF, then I don't think it's possible.
With GEF, you can make use of a
DirectEditManager
in an Edit Part, and create an Edit Policy (extendingDirectEditPolicy
, installed with the keyEditPolicy.DIRECT_EDIT_ROLE
) to allow a direct edit to be performed on a figure.You could create a figure which extends
Label
that is styled to look like a text box, and activate (by overridingperformRequest
in the Edit Part) editing upon selection.This Schema Diagram example contains this type of functionality (and more importantly, the code!), although the figure used for edit (
EditableLabel
) isn't styled to look like a text box, and the activation itself is on double-click rather than selection.It may point you in the right direction though.