SWT 常用事件

KeyEvent

character  (Ctrl  + A , 代表的是A字符)
 The Unicode value of the character (e.g., \u0041 for A)
 
keyCode  (Ctrl + A ,  代表的是 sWT.CTRL
 A constant indicating which key was pressed (e.g., SWT.PAGE_UP)
 
stateMask (Ctrl + A, 当没有按下 A 时, 是0, 按下后是Ctrl
 The "state mask" representing keyboard modifiers (e.g., SWT.SHIFT)

 state Mask modify key
 Table 2.5. Specific Modifier Key State Masks
 
 Modifier Mask           Description
 
SWT.CONTROL              The <Ctrl> key was down (same as SWT.CTRL)
 
SWT.SHIFT                     The <Shift> key was down
 
SWT.ALT                         The <Alt> key was down
 
SWT.COMMAND            The <Command> key was down (Window平台没有)


Table 2.6. Generic Modifier Key State Masks

Modifier Mask                       Description
 
SWT.MOD1                            The first modifier was down (often SWT.CONTROL)
 
SWT.MOD2                             The second modifier was down (often SWT.SHIFT)
 
SWT.MOD3                            The third modifier was down (often SWT.ALT)
 
SWT.MOD4                            The fourth modifier was down (often zero)
 
SWT.MODIFIER_MASK            Bitwise-OR of all valid modifiers

//CORRECT – works when new modifier masks are added
if ((event.stateMask & SWT.MODIFIER_MASK) == 0) {

    System.out.println("No modifiers are down");

}


Traversal Event
有两种方式: 快捷键 和 Tab
Table 2.7. Mnemonic Strings

String                  Result
 
"&File"                  File
 
"T&able"              Table
 
"This && That"     This & That

Composite.setTabList() : 显示的设置Compostie 中控件的table ordering.

Table 2.9. Public Fields of Class Event Valid during SWT.Traverse

Field                          Description
 
detail                         The traversal code
 
doit                            Setting doit to false cancels the traversal operation. The default value indicates whether the particular traversal operation would
                                  normally be performed by the control. For controls that you write, doit is always false.


Table 2.11. The doit and detail Fields

doit                 detail                       Traversal Performed          Key Event
 
true               Don't assign                         Yes                               No
 
false             Don't assign                           No                               Yes
 
true             SWT.TRAVERSE_NONE            No                        No
 
false            SWT.TRAVERSE_NONE            No                        Yes

 

Accelerator
item.setText("Select &All\tCtrl+A");

item.setAccelerator(SWT.MOD1 + 'A');

item.addListener(SWT.Selection, new Listener() {

    public void handleEvent(Event e) {

        System.out.println("The item was selected.");

    }

});

 

 

 

 


 

 

 


 

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值