我想向我的卢布添加一个多行输入对话框
好吧,我真的很希望能够向我的卢布添加多行(文本区域)InputDialog。
我已经解决了 Ruble::UI 中的限制,并创建了自己的模块,当我想要比 Ruble::UI 提供的默认对话框更多的内容时,我会用我的卢布加载该模块。因此,我已经能够添加多选对话框,甚至通过创建一个覆盖类,然后向 getTextStyle 方法传递我自己的值以使其成为多行,从而使多行输入对话框能够工作。
问题在于,对话框显示了一个多行文本框,但它的高度仍然设置为一行,因此它本质上仍然只是一个单行框。我从 Eclipse 插件开发知道如何在 Java 中创建多行对话框,我只是不知道如何使用 jruby 在卢布中实现它。
这是我当前在 ruby 中的代码,
用于请求多对话框
class MultiInputDialog < org.eclipse.jface.dialogs.InputDialog
def getInputTextStyle
org.eclipse.swt.SWT::MULTI | org.eclipse.swt.SWT::BORDER | org.eclipse.swt.SWT::V_SCROLL
end
end
,这是在 Java 中执行此操作的代码所需的内容。
Java 覆盖
InputDialog dlg = new InputDialog(Display.getCurrent().getActiveShell(), "Test", "Please input text.",
"Test-Text", null) {
/**
* Override this method to make the text field multilined
* and give it a scroll bar. But...
*/
@Override
protected int getInputTextStyle() {
return SWT.MULTI | SWT.BORDER | SWT.V_SCROLL;
}
/**
* ...it still is just one line high.
* This hack is not very nice, but at least it gets the job done... ;o)
*/
@Override
protected Control createDialogArea(Composite parent) {
Control res = super.createDialogArea(parent);
((GridData) this.getText().getLayoutData()).heightHint = 100;
return res;
}
};
dlg.open();
所以你可以看到我已经弄清楚了如何覆盖 getInputTextStyle,但是我尝试模仿 createDialogArea() 覆盖的一切都失败了。任何建议或帮助将不胜感激
Ok so I would really like to be able to add a multiline (textarea) InputDialog to my ruble.
I've worked around the limitations in Ruble::UI and created my own module that I load with my ruble when I want more then the default dialogs the Ruble::UI provides. Because of this I've been able to add multiselect dialogs and even gotten the Multiline InputDialog to work by creating a override class and then passing the getTextStyle method my own values to make it multiline.
The problem comes in that the dialog displays a multiline text box but it's height is still set to one line, so it essentially still just a single line box. I know from Eclipse plugin dev how to create the multiline dialog in Java, I just can't figure out how to make it happen in a ruble using jruby.
Here is my current code in ruby
Used to request a Multi Dialog
class MultiInputDialog < org.eclipse.jface.dialogs.InputDialog
def getInputTextStyle
org.eclipse.swt.SWT::MULTI | org.eclipse.swt.SWT::BORDER | org.eclipse.swt.SWT::V_SCROLL
end
end
And here is what the code to do it in Java would like.
Java override
InputDialog dlg = new InputDialog(Display.getCurrent().getActiveShell(), "Test", "Please input text.",
"Test-Text", null) {
/**
* Override this method to make the text field multilined
* and give it a scroll bar. But...
*/
@Override
protected int getInputTextStyle() {
return SWT.MULTI | SWT.BORDER | SWT.V_SCROLL;
}
/**
* ...it still is just one line high.
* This hack is not very nice, but at least it gets the job done... ;o)
*/
@Override
protected Control createDialogArea(Composite parent) {
Control res = super.createDialogArea(parent);
((GridData) this.getText().getLayoutData()).heightHint = 100;
return res;
}
};
dlg.open();
So you can see I've figured out how to override the getInputTextStyle, but everthing I've tried to mimic the override of createDialogArea() has falied. Any suggestions or help would be greatly appreciated
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
试试这个:
干杯,
最大限度
Try this:
Cheers,
Max