SWT:如何为文本字段重新创建默认上下文菜单 [英] SWT: How to recreate a default context menu for text fields

查看:140
本文介绍了SWT:如何为文本字段重新创建默认上下文菜单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在SWT中的文本控件的默认上下文菜单中添加一些项目,但是已经发现我无法修改此菜单并且必须从头开始创建一个新项目。

I need to add some items to the default context menu of a text control in SWT, but already found out I cannot modify this menu and have to create a new one from scratch.

但是如何模拟默认功能撤消,剪切,复制,粘贴,删除?我真的必须为自己重新实现所有这些剪贴板的东西吗?我甚至不知道如何访问控件的撤消历史记录。是否有一些可能是肮脏的黑客来模仿实现该功能的密钥代码?

But how do I emulate the default functions Undo, Cut, Copy, Paste, Delete? Do I really have to re-implement all this Clipboard stuff for myself? And I don't even know how to access the Undo history of the control. Is there some maybe dirty hack to emulate the key codes that achieve the functionality?

推荐答案

StyledText 内置支持Cut,Copy&粘贴:

The StyledText has built-in support for Cut, Copy & Paste:

StyledText editor = new StyledText(...);
editor.invokeAction(ST.CUT);
editor.invokeAction(ST.COPY);
editor.invokeAction(ST.PASTE);

至于撤销操作,我担心你必须自己实施。 SWT 这里没有任何有用的东西,AFAIK。如果您想自己动手,这是一个良好的开端: SWT撤消重做

As for the Undo operation, I'm afraid you'll have to implement it yourself. SWT doesn't have anything useful here, AFAIK. Here's a good start if you want to do it yourself: SWT Undo Redo.

这篇关于SWT:如何为文本字段重新创建默认上下文菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆