开发者

Disposing a dialog in touch devices in lwuit

开发者 https://www.devze.com 2022-12-21 21:55 出处:网络
I am displaying a dialog when a user touches the screen and want the dialog to dispose when the user touches anywhere outside the dialog. I have set setDisposeWhenPointerOutOfBounds() to tr开发者_Go百

I am displaying a dialog when a user touches the screen and want the dialog to dispose when the user touches anywhere outside the dialog. I have set setDisposeWhenPointerOutOfBounds() to tr开发者_Go百科ue though by default it is. And I have written the following code in pointerReleased() event but whenever the user touches the screen outside of dialog the dialog disposes but not without executing the code that should be executed only when the x,y are within the dialog.

public void pointerReleased(int x, int y) {
    dispose();
    if (contains(x, y)) {
        actionCommand((cmds[l.getSelectedIndex()]));
    }
}


the bug was in checking contains(x,y). I replaced it with this.getContentPane.contains(x,y) and that has fixed the issue

0

精彩评论

暂无评论...
验证码 换一张
取 消