Jump to: navigation, search

How to enable resizing while activating VKB in eRCP

Revision as of 22:35, 15 March 2010 by Johnhsu.tw.ibm.com (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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);
       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) {
   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.