| 
| Prevent ESC from closing a Dialog [message #1858217] | Thu, 23 March 2023 05:59  |  | 
| Eclipse User  |  |  |  |  | Gentlemen, 
 i am evaluating the RWT a bit. I m just wondering why ESC closes a new Shell/Dialog per default.  Maybe that s just a simple question...
 
 BTW: the gridData.hightHint ist not working for the Text Widget. I just wanted to make it MultiLine with a height of 5 lines ....  This is also probably just related to how one should handle things with the RWT.
 
 
 
Shell dialog = new Shell(parent.getShell(), SWT.APPLICATION_MODAL);
                dialog.setMinimumSize(parent.getShell().getSize().x - 200, 0);
                dialog.setLocation(100, 0);
                dialog.setLayout(new GridLayout(1, false));
                Text t = new Text(dialog, SWT.MULTI | SWT.BORDER | SWT.WRAP | SWT.V_SCROLL);
                GridData gridData = new GridData(SWT.FILL, SWT.CENTER, true, false);
                gridData.heightHint = 50;
                t.setText("USE CRTL for a MNEMONIC demo ...  or crtl+x ESC or d to check for hotkey handling");
                Button closeButton = new Button(dialog, SWT.NONE);
                closeButton.setText("&E Close");
                closeButton.addSelectionListener(new SelectionAdapter() {
                    @Override
                    public void widgetSelected(SelectionEvent e) {
                        dialog.close();
                    }
                });
                dialog.setData(RWT.CANCEL_KEYS, new String[]{"ESC"});
                dialog.setData(RWT.ACTIVE_KEYS, new String[]{"CTRL+X"});
                dialog.addKeyListener(new KeyListener() {
                    @Override
                    public void keyPressed(KeyEvent keyEvent) {
                        t.setText("Key Event here " + keyEvent) ;
                        keyEvent.doit = false;
                    }
                    @Override
                    public void keyReleased(KeyEvent keyEvent) {
                    }
                });
                dialog.pack();
                dialog.open();
 Any suggestion or hint appreciated,
 Daniel
 
 |  |  |  | 
|  | 
|  | 
|  | 
Powered by 
FUDForum. Page generated in 0.03953 seconds