Jump to: navigation, search

Difference between revisions of "How to enable resizing while activating VKB in eRCP"

(New page: You need to do three things in order to enable resizing while activating vitual keyboard in eRCP: 1. You need anoher shell under your top level shell because the top level shell can't be ...)
 
 
Line 4: Line 4:
  
 
2. You need to set layout for the second shell so that the shell doesn't expand out of the screen.  
 
2. You need to set layout for the second shell so that the shell doesn't expand out of the screen.  
 +
 +
        shell = new Shell(display);
 +
        shell.setBounds(display.getBounds());
 +
       
 +
        shell2 = new Shell(shell, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
 +
        shell2.setLayout(new FillLayout());
  
 
3. This is the most tricky one, The eRCP does not handle virtual keyboard
 
3. This is the most tricky one, The eRCP does not handle virtual keyboard
 
resizing. It is done by windows mobile itself. However, here is a trick to make
 
resizing. It is done by windows mobile itself. However, here is a trick to make
 
it automatically resized when virtual keyboard is activated. You just need to
 
it automatically resized when virtual keyboard is activated. You just need to
make your widget 1 pixel smaller than the top level shell like this:
+
add a listener to catch the resize event, and when the virtual keyboard is activated
 +
, the resize event will be sent, and then make your widget 1 pixel smaller than the  
 +
top level shell in the callback function like this:
 +
 
  
 +
    shell.addListener(SWT.Resize, new Listener() {
 +
                public void handleEvent(Event event) {
 +
                        adjustSize();
 +
                }
 +
    });
 
     public static void adjustSize() {
 
     public static void adjustSize() {
 
         Rectangle rect = shell.getBounds();
 
         Rectangle rect = shell.getBounds();

Latest revision as of 22:35, 15 March 2010

You need to do three things in order to enable resizing while activating vitual keyboard in eRCP:

1. You need anoher shell under your top level shell because the top level shell can't be resized.

2. You need to set layout for the second shell so that the shell doesn't expand out of the screen.

       shell = new Shell(display);
       shell.setBounds(display.getBounds());
       
       shell2 = new Shell(shell, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
       shell2.setLayout(new FillLayout());

3. This is the most tricky one, The eRCP does not handle virtual keyboard resizing. It is done by windows mobile itself. However, here is a trick to make it automatically resized when virtual keyboard is activated. You just need to add a listener to catch the resize event, and when the virtual keyboard is activated , the resize event will be sent, and then make your widget 1 pixel smaller than the top level shell in the callback function like this:


   shell.addListener(SWT.Resize, new Listener() {
               public void handleEvent(Event event) {
                       adjustSize();
               }
   });
   public static void adjustSize() {
       Rectangle rect = shell.getBounds();
       shell2.setBounds(rect.x + 1, rect.y + 1, rect.width - 1, rect.height -1);
   }

you need to use setBounds, notsetSize, and on the second shell instead of the top level shell.