使用Tabris在iOS中隐藏键盘

使用Tabris在iOS中隐藏键盘,ios,eclipse,Ios,Eclipse,是否有从iOS屏幕上删除键盘的选项?我用Tabris(http://developer.eclipsesource.com/tabris/)在这种情况下,我们可以使用Java 我的问题是,我使用两个文本字段来输入user/passwort组合。在我填写这些文本字段并按下按钮继续后,iOS中的键盘将始终显示,但我希望不再显示键盘。只有在我点击某个地方后,键盘才会消失 是否设置了UITextField委托并在其中添加了以下方法 - (BOOL)textFieldShouldReturn:(UITex

是否有从iOS屏幕上删除键盘的选项?我用Tabris(http://developer.eclipsesource.com/tabris/)在这种情况下,我们可以使用Java


我的问题是,我使用两个文本字段来输入user/passwort组合。在我填写这些文本字段并按下按钮继续后,iOS中的键盘将始终显示,但我希望不再显示键盘。只有在我点击某个地方后,键盘才会消失

是否设置了UITextField委托并在其中添加了以下方法

- (BOOL)textFieldShouldReturn:(UITextField *)textField {
    [textField resignFirstResponder];
    return YES;
}
在Tabris上,您可以通过将焦点设置在使用键盘的控件(如org.eclipse.swt.widgets.Text)上,以编程方式“打开”键盘。 要隐藏键盘,只需将焦点设置为不需要键盘的控件,如文本字段的父组合

在您的情况下,我会在按钮的SelectionListener中添加一行,将焦点设置在文本字段的父字段上,然后启动登录过程

下面是一些代码,用于播放和理解焦点机制:

public class FocusTest implements EntryPoint {

public int createUI() {
    Display display = new Display();
    Shell shell = new Shell(display, SWT.NO_TRIM);
    shell.setMaximized(true);
    GridLayoutFactory.fillDefaults().applyTo(shell);
    createContent(shell);
    shell.open();
    //while (!shell.isDisposed()) {
    //  if (!display.readAndDispatch()) {
    //      display.sleep();
    //  }
    //}
    return 0;
}

private void createContent(final Composite parent) {
    Button buttonSingleText = new Button(parent, SWT.PUSH);
    buttonSingleText.setText("Focus on SingleText");
    GridDataFactory.fillDefaults().grab(true, false).align(SWT.FILL, SWT.CENTER).applyTo(buttonSingleText);

    Button buttonMultiText = new Button(parent, SWT.PUSH);
    buttonMultiText.setText("Focus on MultiText");
    GridDataFactory.fillDefaults().grab(true, false).align(SWT.FILL, SWT.CENTER).applyTo(buttonMultiText);

    Button buttonNoFocus = new Button(parent, SWT.PUSH);
    buttonNoFocus.setText("Loose Focus");
    GridDataFactory.fillDefaults().grab(true, false).align(SWT.FILL, SWT.CENTER).applyTo(buttonNoFocus);

    final Text singleText = new Text(parent, SWT.SINGLE);
    GridDataFactory.fillDefaults().grab(true, false).align(SWT.FILL, SWT.CENTER).applyTo(singleText);

    final Text multiText = new Text(parent, SWT.MULTI);
    GridDataFactory.fillDefaults().grab(true, false).align(SWT.FILL, SWT.CENTER).applyTo(multiText);

    buttonSingleText.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            singleText.setFocus();
        }
    });
    buttonMultiText.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            multiText.setFocus();
        }
    });
    buttonNoFocus.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            parent.setFocus();
        }
    });
}
}

我试过这个例子,但“焦距松弛”按钮不能正常工作。我在iPhone模拟器中试过,键盘不会隐藏。