久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

    • <bdo id='DfdYs'></bdo><ul id='DfdYs'></ul>

    <small id='DfdYs'></small><noframes id='DfdYs'>

      <i id='DfdYs'><tr id='DfdYs'><dt id='DfdYs'><q id='DfdYs'><span id='DfdYs'><b id='DfdYs'><form id='DfdYs'><ins id='DfdYs'></ins><ul id='DfdYs'></ul><sub id='DfdYs'></sub></form><legend id='DfdYs'></legend><bdo id='DfdYs'><pre id='DfdYs'><center id='DfdYs'></center></pre></bdo></b><th id='DfdYs'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='DfdYs'><tfoot id='DfdYs'></tfoot><dl id='DfdYs'><fieldset id='DfdYs'></fieldset></dl></div>
      <legend id='DfdYs'><style id='DfdYs'><dir id='DfdYs'><q id='DfdYs'></q></dir></style></legend>
      1. <tfoot id='DfdYs'></tfoot>
      2. 如何在我的 SWT 應用程序中檢測 ctrl-f

        How to detect ctrl-f in my SWT application(如何在我的 SWT 應用程序中檢測 ctrl-f)

          1. <i id='HxXKF'><tr id='HxXKF'><dt id='HxXKF'><q id='HxXKF'><span id='HxXKF'><b id='HxXKF'><form id='HxXKF'><ins id='HxXKF'></ins><ul id='HxXKF'></ul><sub id='HxXKF'></sub></form><legend id='HxXKF'></legend><bdo id='HxXKF'><pre id='HxXKF'><center id='HxXKF'></center></pre></bdo></b><th id='HxXKF'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='HxXKF'><tfoot id='HxXKF'></tfoot><dl id='HxXKF'><fieldset id='HxXKF'></fieldset></dl></div>
          2. <legend id='HxXKF'><style id='HxXKF'><dir id='HxXKF'><q id='HxXKF'></q></dir></style></legend>

            • <bdo id='HxXKF'></bdo><ul id='HxXKF'></ul>

              <small id='HxXKF'></small><noframes id='HxXKF'>

              <tfoot id='HxXKF'></tfoot>
                  <tbody id='HxXKF'></tbody>

                  本文介紹了如何在我的 SWT 應用程序中檢測 ctrl-f的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我編寫了一個 SWT UI,它的主要功能是在 StyledText 控件中顯示文本.我想為 Ctrl+F 添加一個處理程序,以便在按下該快捷方式時將焦點設置為搜索框.我嘗試使用以下代碼來檢測按鍵.

                  I have written an SWT UI which has a primary function of displaying text in a StyledText control. I want to add a handler for Ctrl+F so that when that shortcut is pressed the focus is set to a search box. I have tried using the following code to detect the keypress.

                  sWindow = new Shell();
                  ...
                  sWindow.getDisplay().addFilter(SWT.KeyDown, new Listener()
                  {
                    @Override
                    public void handleEvent(Event e)
                    {
                      System.out.println("Filter-ctrl: " + SWT.CTRL);
                      System.out.println("Filter-mask: " + e.stateMask);
                      System.out.println("Filter-char: " + e.character);
                    }
                  });
                  

                  我期待當我按下 Ctrl+f 時,我會看到以下輸出:

                  I was expecting that when I pressed Ctrl+f I would see the following output:

                  Filter-ctrl: 262144
                  Filter-mask: 262144
                  Filter-char: f
                  

                  但是,在實踐中,我實際上看到了以下內容.

                  However, in practice I actually see the following.

                  Filter-ctrl: 262144
                  Filter-mask: 262144
                  Filter-char: <unprintable char - displayed as a box in eclipse console>
                  

                  我有兩個問題:

                  • Display.addFilter(...) 是添加全局快捷方式的最佳方式嗎?我試過 Display.addListener(...) 但這根本沒有收到任何事件.
                  • 為什么我在按住 Ctrl 的時候沒有得到按下的字符?當我按住 alt 或 shift 時,我得到了預期的掩碼和按下的字符.
                  • Is Display.addFilter(...) the best way to add a global shortcut? I tried Display.addListener(...) but this didn't receive any events at all.
                  • Why don't I get the pressed character when I'm holding down Ctrl? When I hold down alt or shift I get the expected mask and the pressed character.

                  推薦答案

                  Display.addFilter(...) 是添加全局快捷方式的最佳方式嗎?我試過 Display.addListener(...) 但這根本沒有收到任何事件.

                  是的,通常 Display.addFilter(...) 是添加 glbal 快捷方式的最佳方式,因為它們比事件偵聽器具有更高的偏好.請參閱 Display.addFilter(...) javadoc 中的以下注釋.

                  Yes, normally Display.addFilter(...) is the best way to add a glbal shortcut because they have higher preference over the event listeners. See the below comment from Display.addFilter(...) javadoc.

                  因為事件過濾器在其他過濾器之前運行監聽器,事件過濾器都可以阻止其他偵聽器并設置事件中的任意字段.為了因此,事件過濾器都是強大而危險.他們應該通常為了性能而避免,調試和代碼維護原因.

                  Because event filters run before other listeners, event filters can both block other listeners and set arbitrary fields within an event. For this reason, event filters are both powerful and dangerous. They should generally be avoided for performance, debugging and code maintenance reasons.

                  <小時>第二個問題:

                  為什么我在按住 ctrl 時沒有得到按下的字符?當我按住 alt 或 shift 時,我得到了預期的掩碼和按下的字符.

                  問題是你看錯了地方.您應該使用 e.keyCode 而不是查詢 e.character.根據 e.character 的 javadoc,您不會只得到字符 f:

                  The problem is that you are looking at the wrong place. Instead of querying e.character you should be using e.keyCode. As per javadoc of e.character you won't get just character f:

                  根據事件,角色由鍵入的鍵表示.這是最后一個角色所有修飾符后的結果應用.例如,當用戶鍵入Ctrl+A,字符值為0x01 (ASCII SOH).

                  Depending on the event, the character represented by the key that was typed. This is the final character that results after all modifiers have been applied. For example, when the user types Ctrl+A, the character value is 0x01 (ASCII SOH).

                  因此,當您按下 CTRL+f 時,它會轉換為 0x06(ASCII ACK).當您執行 ALT+f SHIFT+f 時,情況并非如此.

                  So when you press CTRL+f then it converts in 0x06 (ASCII ACK). Which is not the case when you do ALT+f or SHIFT+f.

                  另一方面,e.keyCode 的 javadoc 說:

                  On the other hand the javadoc of e.keyCode says:

                  根據事件,關鍵代碼鍵入的鍵,如定義的那樣通過類中的關鍵代碼常量SWT.當字符字段事件不明確,這個字段包含不受影響的值原始字符.例如,鍵入 Ctrl+M 或 Enter both 結果字符 ' ' 但 keyCode字段也將包含 ' ' 時當 Ctrl+M 時輸入了 Enter 和 'm'已輸入.

                  depending on the event, the key code of the key that was typed, as defined by the key code constants in class SWT. When the character field of the event is ambiguous, this field contains the unaffected value of the original character. For example, typing Ctrl+M or Enter both result in the character ' ' but the keyCode field will also contain ' ' when Enter was typed and 'm' when Ctrl+M was typed.

                  查看以下代碼了解更多詳情.對于演示,我嘗試將偵聽器放在 DisplayTest 上.

                  Check the below code for more details. For demo I have tried to put listener on Display and Test.

                  import org.eclipse.swt.SWT;
                  import org.eclipse.swt.events.KeyEvent;
                  import org.eclipse.swt.events.KeyListener;
                  import org.eclipse.swt.graphics.Color;
                  import org.eclipse.swt.widgets.Display;
                  import org.eclipse.swt.widgets.Event;
                  import org.eclipse.swt.widgets.Listener;
                  import org.eclipse.swt.widgets.Shell;
                  
                  public class ControlF 
                  {
                      public static void main(String[] args) 
                      {
                  
                          Display display = new Display ();
                  
                          final Shell shell = new Shell (display);
                          final Color green = display.getSystemColor (SWT.COLOR_GREEN);
                          final Color orig = shell.getBackground();
                  
                          display.addFilter(SWT.KeyDown, new Listener() {
                  
                              public void handleEvent(Event e) {
                                  if(((e.stateMask & SWT.CTRL) == SWT.CTRL) && (e.keyCode == 'f'))
                                  {
                                      System.out.println("From Display I am the Key down !!" + e.keyCode);
                                  }
                              }
                          });
                  
                          shell.addKeyListener(new KeyListener() {
                              public void keyReleased(KeyEvent e) {
                                  if(((e.stateMask & SWT.CTRL) == SWT.CTRL) && (e.keyCode == 'f'))
                                  {
                                      shell.setBackground(orig);
                                      System.out.println("Key up !!");
                                  }
                              }
                              public void keyPressed(KeyEvent e) {
                                  if(((e.stateMask & SWT.CTRL) == SWT.CTRL) && (e.keyCode == 'f'))
                                  {
                                      shell.setBackground(green);
                                      System.out.println("Key down !!");
                                  }
                              }
                          });
                  
                          shell.setSize (200, 200);
                          shell.open ();
                          while (!shell.isDisposed()) {
                              if (!display.readAndDispatch ()) display.sleep ();
                          }
                          display.dispose ();
                  
                      }
                  }
                  

                  這篇關于如何在我的 SWT 應用程序中檢測 ctrl-f的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  How can I detect integer overflow on 32 bits int?(如何檢測 32 位 int 上的整數溢出?)
                  Local variables before return statements, does it matter?(return 語句之前的局部變量,這有關系嗎?)
                  How to convert Integer to int?(如何將整數轉換為整數?)
                  How do I create an int array with randomly shuffled numbers in a given range(如何在給定范圍內創建一個隨機打亂數字的 int 數組)
                  Inconsistent behavior on java#39;s ==(java的行為不一致==)
                  Why is Java able to store 0xff000000 as an int?(為什么 Java 能夠將 0xff000000 存儲為 int?)
                1. <i id='gEUin'><tr id='gEUin'><dt id='gEUin'><q id='gEUin'><span id='gEUin'><b id='gEUin'><form id='gEUin'><ins id='gEUin'></ins><ul id='gEUin'></ul><sub id='gEUin'></sub></form><legend id='gEUin'></legend><bdo id='gEUin'><pre id='gEUin'><center id='gEUin'></center></pre></bdo></b><th id='gEUin'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='gEUin'><tfoot id='gEUin'></tfoot><dl id='gEUin'><fieldset id='gEUin'></fieldset></dl></div>

                  <small id='gEUin'></small><noframes id='gEUin'>

                    <tbody id='gEUin'></tbody>

                  • <bdo id='gEUin'></bdo><ul id='gEUin'></ul>

                        <tfoot id='gEUin'></tfoot>
                            <legend id='gEUin'><style id='gEUin'><dir id='gEUin'><q id='gEUin'></q></dir></style></legend>
                          1. 主站蜘蛛池模板: 亚洲视频一区在线观看 | 91视频精选 | 国产在线精品一区二区 | 日本精品视频在线 | 国产综合久久久久久鬼色 | 亚洲精品国产第一综合99久久 | 中文字幕一区二区三区四区五区 | 中文字幕第90页 | 中文字幕高清一区 | 欧美在线综合 | 黄色国产| 国家aaa的一级看片 h片在线看 | 男女网站视频 | 日韩综合在线播放 | 亚洲一区视频 | 欧美在线视频网 | 欧美午夜一区二区三区免费大片 | 中文字幕视频在线免费 | 欧美成年黄网站色视频 | aa级毛片毛片免费观看久 | 成人午夜网站 | 午夜寂寞影院在线观看 | 久久久久91 | 久久成人激情 | 天天色天天色 | 国产夜恋视频在线观看 | 四虎成人免费视频 | 精品欧美一区二区三区久久久 | 亚洲一区二区三区福利 | 影音先锋中文字幕在线观看 | h视频在线免费观看 | 中文字幕精品视频 | www久久久 | 亚洲精品久久久久久一区二区 | 国产成人久久精品 | 超碰av在线 | 欧美日韩综合视频 | 欧美日产国产成人免费图片 | 成人免费网站 | 怡红院免费的全部视频 | 在线成人一区 |