MANISH
MANISH

Reputation: 11

Disposing a dialog in touch devices in lwuit

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 true 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()]));
    }
}

Upvotes: 0

Views: 809

Answers (1)

MANISH
MANISH

Reputation: 11

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

Upvotes: 1

Related Questions