SWT/Jface SelectionlIstener

 SelectionListener listener = new SelectionListener(){
   public void widgetSelected(SelectionEvent e) {
    System.out.println("widgetSelected事件");
   }
   public void widgetDefaultSelected(SelectionEvent e) {
    System.out.println("widgetDefaultSelected事件");
    
   }
  };

对于selection的监听一直很好奇,为什么会有2个方法,什么控件执行什么方法?

widgetDefaultSelected

void widgetDefaultSelected(SelectionEvent e)
Sent when default selection occurs in the control.

For example, on some platforms default selection occurs in a List when the user double-clicks an item or types return in a Text. On some platforms, the event occurs when a mouse button or key is pressed. On others, it happens when the mouse or key is released. The exact key or mouse gesture that causes this event is platform specific.

Parameters:
e - an event containing information about the default selection

官方的api说的也很泛泛。我们直观的理解就是List 这个控件在双击的时候会触发widgetDefaultSelected的方法,但是同时也会触发widgetSelected这个方法,所以我觉得就没default存在的必要了。

真正的开发中真没遇到widgetDefaultSelected方法来处理业务逻辑时候,求解释??

 

以下是老外的说法:

Use widgetSelected. In fact, all the better is to simply extend SelectionAdapter and only override the widgetSelected method and completely ignore widgetDefaultSelected.

 

和咱的想法是一样的。

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值