views:

58

answers:

1

Is there a way to add a redraw callback to a live screen object, i.e. not via inheritance?


Reasoning:
I want to draw an overlay from an extension for widget sdk (substituting jumpy position:fixed), so the screen is created by the bbwp stub.

I can get it by

Ui.getUiEngine().getActiveScreen()

and draw on it quite nicely, but I need a way to redraw when appropriate.


Note:
I've abandoned the approach to push the overlay as a screen, because i couldn't make it transparent / find a way to pass events through.

+1  A: 

If you want to push the overlay as a screen, you should be able to make it's background transparent by overriding the paintBackground() method as follows:

// Make background transparent
protected void paintBackground(Graphics graphics) {
    XYRect xy = graphics.getClippingRect();
    graphics.pushContext(xy, 0, 0);
    graphics.setGlobalAlpha(0);
    graphics.setColor(0xffffff);
    graphics.fillRect(xy.x, xy.y, xy.width, xy.height);
    graphics.popContext();
}

Then, to pass touch events through, override the following method and return -1 if you don't want your screen to handle the touch event:

public int getFieldAtLocation(int x, int y) {
    return -1;
}
Marc Novakowski
Thanks, I'll try that tomorrow
Bendlas