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
huddarveena
Posts: 103
Registered: ‎12-12-2011
My Device: Developer
Accepted Solution

Navigation click of Manager affecting ActiveRichTextField present inside the manager.

Hello All,

          I have a custom HorizontalFieldManager containig different fields, among which ActiveRichTextField is one of them. I have given a navigation click for the manager through the code:

protected boolean navigationClick(int status, int time) {
        if(Touchscreen.isSupported()){
            return false;
        }else{
            fieldChangeNotify(1);
            return true;
        }
    }
    
    protected boolean touchEvent(TouchEvent message)
    {
        if(TouchEvent.DOWN == message.getEvent()){
            FieldChangeListener listener = getChangeListener();
            if(listener != null)
                this.setFocus();
        }
        
        if (TouchEvent.CLICK == message.getEvent())
        {
            FieldChangeListener listener = getChangeListener();
            if (null != listener)
                this.setFocus();
                listener.fieldChanged(this, 1);
        }
        return super.touchEvent(message);
    }

 

and then handling the touch using FieldChangeListener. When I click on the ActiveRichTextField, contained within horizontal field manager, action for click on manager is executed. Can someone please tell how can this be avoided. Thanks in advance.

Developer
simon_hain
Posts: 16,282
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport

Re: Navigation click of Manager affecting ActiveRichTextField present inside the manager.

if you want to consume the event return true
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
huddarveena
Posts: 103
Registered: ‎12-12-2011
My Device: Developer

Re: Navigation click of Manager affecting ActiveRichTextField present inside the manager.

If I return true in the touchEvent(), it does not call fieldChanged() and action for the manager is working fine. But if I click on ActiveRichTextField for a phone number, action for both ActiveRichTextField and manager are executed. I wanna avoid action for manager getting executed, when I click on ActiveRichTextField.

Developer
simon_hain
Posts: 16,282
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport

Re: Navigation click of Manager affecting ActiveRichTextField present inside the manager.

in navigationclick
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
huddarveena
Posts: 103
Registered: ‎12-12-2011
My Device: Developer

Re: Navigation click of Manager affecting ActiveRichTextField present inside the manager.

Hi simon_hain, I tried both but no luck please tell me what am I doing wring here, how can i get the solution. Thank u.

Developer
peter_strange
Posts: 19,610
Registered: ‎07-14-2008
My Device: Not Specified

Re: Navigation click of Manager affecting ActiveRichTextField present inside the manager.

Some questions

 

1) Why are you trying to detect touchEvent in the Manager? 

2) How does this help you when you could detect the same thing in the focused Field?

3) Other than the the ActiveRichTextField, what Fields are included in your Manager?

 

4) When you were returning true, you should have done this for events that you processed, not for all events.  Is this what you did?  

 

For example

 

    protected boolean touchEvent(TouchEvent message)
    {
        if(TouchEvent.DOWN == message.getEvent()){
            FieldChangeListener listener = getChangeListener();
            if(listener != null)
                this.setFocus();

return true
        }
        
        if (TouchEvent.CLICK == message.getEvent())
        {
            FieldChangeListener listener = getChangeListener();
            if (null != listener)
                this.setFocus();
                listener.fieldChanged(this, 1);
return true;

        }
        return super.touchEvent(message);
    }

 

 

Developer
huddarveena
Posts: 103
Registered: ‎12-12-2011
My Device: Developer

Re: Navigation click of Manager affecting ActiveRichTextField present inside the manager.

Hi Peter, I have given touch event for manager, because the manager represents an item which contains its details embedded within it, in the form of fields. For ex. Name, Location, Phone number etc.

Other than ActiveRichTextField, I have label field, RichTextField and Textfield. I need to give touvh event for ActiveRichTextField as it has to perform it's default action.

If I return true in touch event, as suggested by u, I am not getting the solution.

Please tell me what can be done. Let me know, whether the implementation I have done is feasible or I cannot give focus to entire manager, if I wana process focus/touch for ActiveRichTextField. Thank u.

Developer
peter_strange
Posts: 19,610
Registered: ‎07-14-2008
My Device: Not Specified

Re: Navigation click of Manager affecting ActiveRichTextField present inside the manager.

Managers do not really get focus.  Fields get focus.  You can make it look like the Manager gets focus by overriding various methods as you have done. 

 

Two suggestions:

 

a) Check in your processing for the Manager, to see if the Field that has focus is an ActiveRichTextField.  I think you can do this simply by coding something like the following right at the start of your touchEvent() and navigationClick() methods:

 

if ( this.getFieldWithFocus() instanceOf ActiveRichTextField ) {

return super......

}

 

Otherwise leave your processing as is. 

 

b) Make one of your other Fields focusable, and have it process the 'clicks' that you expect to processed by the Manager. 

Developer
huddarveena
Posts: 103
Registered: ‎12-12-2011
My Device: Developer

Re: Navigation click of Manager affecting ActiveRichTextField present inside the manager.

Hi Peter, is it that if present field with focus is instance of ActiveRichTextField I should call super.touchEvent()?

I can't choose only one of the fields to process click event of manager as my requirement is to process the click, on clicking any where on the manager.

Developer
peter_strange
Posts: 19,610
Registered: ‎07-14-2008
My Device: Not Specified

Re: Navigation click of Manager affecting ActiveRichTextField present inside the manager.

"is it that if present field with focus is instance of ActiveRichTextField I should call super.touchEvent()?"

 

Not if you put the code in navigationClick.....!

 

Putting this another way, I mean:

super.<whatever method you are in>(<parameters for the method you are in>);

 

"I can't choose only one of the fields to process click event of manager as my requirement is to process the click, on clicking any where on the manager."

 

I think you can do this, because the touch or trackpad movement will move the focus into one of your Fields, and assuming you only have two focusable Fields in the Manager, then it will be either your ActiveRichTextField or your other Field.  As noted, Managers do not get focus, so by going into a Manager, the BB has to move the focus to a Field.