Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Developer
mohitsharma
Posts: 190
Registered: ‎10-22-2009

manager passing touchevent to all fields

hey guys,

I created  a custom manager containing some cotain fields.

Now manager is passing touchevent to all the containing fields irrespective of the location

where the touch event occurs.

How can i make manager pass touchevent to only the field where it occurs?

-----------------------------------------------------------------------------------
Please mark posts as solved if you found a solution. Press the kudos button to thank the user who helped you.
Please use plain text.
Developer
mohitsharma
Posts: 190
Registered: ‎10-22-2009

Re: manager passing touchevent to all fields

I think its going always to focused field inside the manager eventhough i touchevent not originated

at that coordinate.

Manager is returning super.touchevent() and all fields have their implementation of touchevent().

Is there a way to pass touch event to fields under the location where touch event occurs rather than focused fiel?.

 

 

-----------------------------------------------------------------------------------
Please mark posts as solved if you found a solution. Press the kudos button to thank the user who helped you.
Please use plain text.
Developer
ssaidwho
Posts: 17
Registered: ‎12-31-2009

Re: manager passing touchevent to all fields

I ran across this when changing graphics of a custom button field. When changing between buttons, a touch event could affect the previously focused button and the button that received focus from the touch event. To get around this, I used an 'isPressed' custom flag, and in my paint method this would be used to determine which bitmaps to draw.

 

To get a button to be 'pressed', I overrode these methods for the button class:

 

    protected boolean touchEvent(TouchEvent message) {
    if (message.getEvent() == TouchEvent.DOWN || message.getEvent() == TouchEvent.CLICK) {
        this.isPressed = true;
    } else if (message.getEvent() == TouchEvent.UP)
        this.isPressed = false;
    invalidate();
    return super.touchEvent(message);
    }

    protected void onUnfocus() {
    this.isPressed = false;
    invalidate();
    }

Please use plain text.