[英]Where is the MouseClick event on an SWT Button?
I know this sounds like a very basic question, and I feel embarrassed to ask it but... 我知道这听起来像一个非常基本的问题,我觉得很尴尬但是...
How to I add a Mouse Click handler to an SWT button? 如何将鼠标单击处理程序添加到SWT按钮?
What I checked: 我检查了什么:
Is selection what is commonly known as "OnClick" in other languages/frameworks? 选择在其他语言/框架中通常称为“OnClick”的是什么? Or is there something else that I completely missed? 或者还有其他我完全错过的东西?
Yes, SWT.Selection
or SelectionListener
is what you're looking for: 是的, SWT.Selection
或SelectionListener
是您正在寻找的:
Button button = new Button(shell, SWT.PUSH);
button.addListener(SWT.Selection, new Listener()
{
@Override
public void handleEvent(Event event)
{
System.out.println("SWT.Selection");
}
});
adding a SelectionListener
internally does the same as the code above. 在内部添加SelectionListener
与上面的代码相同。
It might be called selection, because a Button
can be a checkbox or a radion button depending on it's style. 它可能被称为选择,因为Button
可以是复选框或radion按钮,具体取决于它的样式。
Yes SelectionListener
is what you are after. 是SelectionListener
就是你想要的。 I, too, am more of a fan of the OnClick
terminology myself as it is more cut and dry; 我自己也更喜欢OnClick
术语,因为它更加切割和干燥; I digress. 我离题了。
Here is a good example for you to see how it works: http://www.java2s.com/Tutorial/Java/0280__SWT/UsingSelectionListener.htm 以下是一个很好的示例,您可以看到它是如何工作的: http : //www.java2s.com/Tutorial/Java/0280__SWT/UsingSelectionListener.htm
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.