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
Posts: 144
Registered: ‎03-15-2011
My Device: blackberry smart phone
My Carrier: Airtel
Accepted Solution

Problem With the button .... Button not working

My workFlow is like this ... I have taken Three HoriZontalManager one for holding theBackgroundImage of the button and two HoriZontalManager to hold the CustomButton and i am adding the main hfm which hold the button and the background image at top and then i have added the list in a VerticalfieldManager but i dont get the button Working the focus always remains on the list Field. Now when I click on the Button the focus always resides on the First row of the list Field so it always show me the picker which is actually i have implemented on the first row of listfield. How can i Solve it ..

 

Thanks in Advanced..

Please help.

Developer
Posts: 541
Registered: ‎05-17-2009
My Device: Not Specified

Re: Problem With the button .... Button not working

Is your custom button set with Field.FOCUSABLE? I am having trouble understand exactly what's going on in your application. If you could post some code, that would help.

 

Scott

Developer
Posts: 144
Registered: ‎03-15-2011
My Device: blackberry smart phone
My Carrier: Airtel

Re: Problem With the button .... Button not working

[ Edited ]

I set it as you said focusable but nothing changed .... And one thing more, if i add these button and not adding any list field there the button is working ... what can be problem here .... and my class is extending VericalFieldManager which iam displaying on the tabbar button click... please help ..

Developer
Posts: 144
Registered: ‎03-15-2011
My Device: blackberry smart phone
My Carrier: Airtel

Re: Problem With the button .... Button not working

here is code snippet .....

hfmToHoldButtton = new HorizontalFieldManager(){
	public int getPreferredWidth() {
	return fWidth;
	};
	protected void sublayout(int maxWidth, int maxHeight) {
				maxWidth = getPreferredWidth();
        		maxHeight = getPreferredHeight();
        		super.sublayout(maxWidth, maxHeight);
        		setExtent(maxWidth, maxHeight);
			};
			
		};
backCustomButton = new CustomButton(back, back, Field.FOCUSABLE |ButtonField.CONSUME_CLICK , "label"){// This is My customButton....
			
			protected boolean navigationClick(int status, int time) { // Overiding the navigationClick for getting button click
				
				//if(backCustomButton.isFocus())
				Dialog.inform("back button pressed ");
//				return super.navigationClick(status, time);
				return true;
			};
		};

hfmToHoldButtton.setBackground(BackgroundFactory.createBitmapBackground(Bitmap.getBitmapResource(buttonBackground)));// here setting the background of the button
		leftManager = new HorizontalFieldManager();// manager to hold the buttons
		rightManager = new HorizontalFieldManager();//manager to hold the buttons
		nullField = new NullField();
		leftManager.add(backCustomButton);
		leftManager.setPadding(-1, 0, 0, 10);
		rightManager.add(saveCustomButton);
		rightManager.setPadding(0, 0, 0, 200);
		hfmToHoldButtton.add(nullField);
		hfmToHoldButtton.add(leftManager);
		hfmToHoldButtton.add(rightManager);
		HorizontalFieldManager manager = new HorizontalFieldManager();


		manager.add(hfmToHoldButtton);

vfm = new VerticalFieldManager();
vfm.add(manager);
vfm.add(_list);
this.add(vfm);
}

 i have provided the code snippet for doing exactly what i am doing here ...

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

Re: Problem With the button .... Button not working

There seems to be a surplus of Managers onvolved in this process.  have you thought about creating your own manager which lays things out how you want them?

 

One other point of concern to me is this:

          super.sublayout(maxWidth, maxHeight);
        setExtent(maxWidth, maxHeight);

 

If you ask the Manager to lay itself out, I think you must respet its extnts.  Other wise it could well get confused about where things are.  So try removing the setExtent and see if this resolves the Button problem.  It might give us a Format problem, but at least then we will understand where the problem is originating from. 

 

And then there is this:

leftManager.setPadding(-1, 0, 0, 10);

 

Remove the padding from round your buttons and see if this resolves the issue, again formatting is compromised but at least we will have identified the iussue.

 

One final questin, I presume you are only having problems on touch screens?

Developer
Posts: 144
Registered: ‎03-15-2011
My Device: blackberry smart phone
My Carrier: Airtel

Re: Problem With the button .... Button not working

@peter thanks for reply as you said i did the things you have told me to do. But none of the solution worked...I must say that the class where i am adding all these is Extending VerticalFieldManager .. so any other work around for this . The focus never go on the button i changed the Image of the button there i see the focus was changing but when i click on the button it always show me the picker which is implemented in the ListField.. Please guide me to solve this issue...
Developer
Posts: 144
Registered: ‎03-15-2011
My Device: blackberry smart phone
My Carrier: Airtel

Re: Problem With the button .... Button not working

[ Edited ]

public class Myclass Extends VerticalFieldManager implements FieldChangeListner{
//All the previous code .......

}

 

@peter thanks for reply as you said i did the things you have told me to do. But none of the solution worked...I must say that the class where i am adding all these is Extending VerticalFieldManager .. so any other work around for this . The focus never go on the button i changed the Image of the button there i see the focus was changing but when i click on the button it always show me the picker which is implemented in the ListField.. Please guide me to solve this issue...

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

Re: Problem With the button .... Button not working

Can you tell us if you are having problems on touchscreen devices or trackpad devices?

 

Can you tell us in words why you have all those Managers, perhaps we can provide you with a less Manager heavy solution that also works!

Developer
Posts: 144
Registered: ‎03-15-2011
My Device: blackberry smart phone
My Carrier: Airtel

Re: Problem With the button .... Button not working

[ Edited ]

@peter i have to make the screen in which there is title on which i have to make two buttons and after that i have a list field from which user can select time, musicfile, can type some message these all i have implemented in the listfield and the selected values will be displayed on the row of the listfield and at the bottom of the screen there is a Tabbar thats why i have extended my class with VerticalFieldManager and adding it on the DisplayArea ....

So i made button on title bar and when i click on the button the button is not working, I always got the time picker which i have implemented on the first row of the listfield. I dont know how to resolve it. And to make that kind of screen i have  so many managers . You suggest me the workaround  and i did the what you have suggested and checked on trackpad as well as on touch screen Simulator which comes default with the Eclipse jde but i got same problem on all simulators please suggest me some work around to solve this issue . If i can manage with the lesser Managers please tell me how ??  Appreciating for your concern though ...

Thanks 

Developer
Posts: 144
Registered: ‎03-15-2011
My Device: blackberry smart phone
My Carrier: Airtel

Re: Problem With the button .... Button not working

[ Edited ]

Solved the problem i had to check that if the button has the focus then do the work else the Listfield has the focus . So just checked

 In the navigationClick(int status, int time){

if(button.isFocus()){

// Do your work

}else{

// List Field has the focus

}

}

thanks all .. for your concerns