简体   繁体   English

从活动获取信息

[英]Getting information from Event

I'm using ModifyListener to get information from Text that changes. 我正在使用ModifyListener从更改的Text获取信息。

Is there a way to get the Text's text in the listener (like a method of Event e)? 有没有办法在侦听器中获取文本的文本(就像事件e的方法一样)?

Thank you! 谢谢!

Next example helps you : 下一个示例可以帮助您:

Text text = new Text(shell, SWT.SINGLE);
text.addModifyListener(new ModifyListener() {

    @Override
    public void modifyText(ModifyEvent e) {
        Text source = (Text) e.getSource();
        System.out.println("text = " + source.getText());
    }
});
text.pack();

According to docs e.getSource() return: 根据docs e.getSource()返回:

The object on which the Event initially occurred. 最初发生事件的对象。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM