2014-06-18 25 views
0

我正在關注SWT Slider Snippet示例,並且事件詳細信息在fedora上始終爲0又名SWT.NONE,但詳細信息在Windows 7上設置。此示例可在此處找到http://www.java2s.com/Code/Java/SWT-JFace-Eclipse/SWTSliderprintscrolleventdetails.htm,這裏是我正在運行的代碼。爲什麼滑塊的SWT選擇事件從來沒有細節?

public static void main(String[] args) { 
    Display display = new Display(); 
    Shell shell = new Shell(display); 
    final Slider slider = new Slider(shell, SWT.HORIZONTAL); 
    slider.setBounds(10, 10, 200, 32); 
    slider.addListener(SWT.Selection, new Listener() { 
     public void handleEvent(Event event) { 
      String string = "SWT.NONE"; 
      switch (event.detail) { 
       case SWT.DRAG: 
        string = "SWT.DRAG"; 
        break; 
       case SWT.HOME: 
        string = "SWT.HOME"; 
        break; 
       case SWT.END: 
        string = "SWT.END"; 
        break; 
       case SWT.ARROW_DOWN: 
        string = "SWT.ARROW_DOWN"; 
        break; 
       case SWT.ARROW_UP: 
        string = "SWT.ARROW_UP"; 
        break; 
       case SWT.PAGE_DOWN: 
        string = "SWT.PAGE_DOWN"; 
        break; 
       case SWT.PAGE_UP: 
        string = "SWT.PAGE_UP"; 
        break; 
      } 
      System.out.println(slider.getSelection()); 
      System.out.println("Scroll detail -> " + string); 
     } 
    }); 
    shell.open(); 
    while (!shell.isDisposed()) { 
     if (!display.readAndDispatch()) display.sleep(); 
    } 
    display.dispose(); 
} 
+0

Slider的Linux/GTK版本的源代碼似乎設置了詳細信息字段。 –

+0

在詳細信息更新的所有位置拋出Slider類中的斷點後,似乎gtk_button_press_event總是返回0,也就是NONE。這會導致gtk_change_value始終將事件詳細信息設置爲無。 – Lexxicon

回答

1

this bugthis bug被認爲解決了,但我的機器不能正常工作(Ubuntu的12.04 Eclipse版本是開普勒)。

因此提出了新的bug here

請參閱我的帖子SWT Scrollbar events on Linux這裏我說了其他的工作來檢測這些事件。

還等着檢查Eclipse Luna(將於6月25日發佈)。

相關問題