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
Trusted Contributor
jppedroso
Posts: 119
Registered: ‎04-29-2010
My Device: Curve 8520

how to use navigationClick

Hi,

 

I have 5 image buttons on top of screen wich are added to a HFM:

_Image5 = Bitmap.getBitmapResource("refresh3w.png");
	_bitmap5 = new BitmapField(_Image5, ButtonField.CONSUME_CLICK|ButtonField.FOCUSABLE)
		{
			protected boolean navigationClick(int status, int time)
			{
				try
				{				
					// do something
				}
				catch (Exception e)
				{
					System.err.println("Error " + e.getMessage());
					e.printStackTrace(); 
				}				
				return true;
			}			     
		};

 and I have overide NavigationClick for the manager:

protected boolean navigationClick(int status,int time){		
		Field field = this.getFieldWithFocus();
		if(field instanceof ListField)
		{
				UiApplication.getUiApplication().pushScreen(new xScreen());					
			
			return true;
		}
		return super.navigationClick(status, time);
	}

in order to capture LisftField(on middle of screen) clicks.

 

Is this a right approach?

Please send some advise on how to code this.

 

Best Regards

 

 

................................................................................................
Tech On!
PTNews
more at On On On!
Please use plain text.
Super Contributor
tolmachevroman
Posts: 257
Registered: ‎05-05-2011
My Device: 9700

Re: how to use navigationClick

May be I don't understand what you're trying to do, but if I wanted to catch click events on these images I would try to override their own navigationClick firstly. Does the code you posted work, BTW?:smileyhappy:

Please use plain text.
Developer
superdirt
Posts: 541
Registered: ‎05-17-2009
My Device: Not Specified

Re: how to use navigationClick

It looks good to me.


Scott

Please use plain text.
Trusted Contributor
jppedroso
Posts: 119
Registered: ‎04-29-2010
My Device: Curve 8520

Re: how to use navigationClick

[ Edited ]

Hi, tks for the replies.

 

Description of the screen:

On top(using setBanner) I have a HFM wich has 5 buttons(wich are Bimap Fields with navigation click). please see the code on first post. Each button has a different function.

On middle of the screen I have a List field wich when cliked opens a new screeen. To catch the click on the List Field I have overide the Navigation Click for the manager(please see the code on first post)

On bottom of the screen I have a HFM added to setStatus() wich has a label field.

 

When I click on the Button X he starts a new thread wich will update the contents of the LabekField on status bar (setStatus).

 

I have a strange behaviour: After clicking on button X (this maintains the focus on itself) if the focus is on one of the 5 buttons the label field on status bar is completely empty, if I change de focus to the List Field the label field gets correctly updated.

 

According to my description of functionality how should I code in order to achive this?

Do you see any problem having navigation click both of each bitmap button and in the manager?

Please explain me wich is the funtion of  "return super.navigationClick(status, time);" in the manager and 

"return true" on each button navigation click.

 

One more thing, on navigationclick (on manager) the "getFieldWithLeafFocus" method returns the HFM field not the button that was clicked.

 

Best Regards

................................................................................................
Tech On!
PTNews
more at On On On!
Please use plain text.
Developer
superdirt
Posts: 541
Registered: ‎05-17-2009
My Device: Not Specified

Re: how to use navigationClick

On the issue of the LabelField not updating when the focus is on the header buttons, from what I can see I don't think this issue has anything to do with the navigationClick method itself. navigationClick is launched when the field is clicked, then it's up to the developer to work out the logic on what should be done when the click is captured. I regularly use navigationClick on bitmapfields without the call to super.navigationClick. As far as I understand though, the return value of navigationClick normally would have no effect on the preceding logic in the method. I think there is something else going on the UI that's causing the issue of the labelfield not updating immediately.

 

On the issue of getFieldWithLeafFocus returning the HFM, I thought that code was fine, but I might try using getFieldWithLeafFocus on the screen instead of the HFM.

 

Scott

Please use plain text.