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: 19,612
Registered: ‎07-14-2008
My Device: Not Specified

Re: Arc Menu in blackberry

Forums Advisor I
Posts: 501
Registered: ‎03-01-2013
My Device: BlackBerry Z10

Re: Arc Menu in blackberry

Hey

If i used set positionChild then its not working i am getting a error and if i set the Margin to the options then the will appear below the parent element.

 

Like:

 

Click:

 

 

 

 

                                   Button2   Button3

 

 

Button1

Developer
Posts: 354
Registered: ‎06-05-2013
My Device: Blackberry Z10

Re: Arc Menu in blackberry

public TestMainScreen() 
	{
		b1= new ButtonField("Click..");
		b1.setChangeListener(this);
		add(b1);    
		vfm = new VerticalFieldManager();
		add(vfm);
	   
	}
	public void fieldChanged(Field field, int context)
	{
		if(field==b1)
		{
			if(vfm.getFieldCount() == 0)
			{
				horizontal = new HorizontalFieldManager(USE_ALL_WIDTH | USE_ALL_HEIGHT)
				{
					 protected void sublayout(int maxWidth, int maxHeight) 
					 {
						 super.sublayout(maxWidth, maxHeight);
						 setPositionChild(this.getField(0), 0, 0);
						 setPositionChild(this.getField(1), (Display.getWidth() - b3.getWidth())/2 , 20);
						 setPositionChild(this.getField(2), (Display.getWidth() - b4.getWidth()) , 0);
					 }
				 }; 
				b2= new ButtonField("Button1");
				b3=new ButtonField("Button2");
				b4= new ButtonField("Button3");
				horizontal.add(b2);
				horizontal.add(b3);
				horizontal.add(b4);
				vfm.add(horizontal);
				
			}
			else
			{
				vfm.deleteAll();
			}
		}
	}

 try this code and study links that has been provided by peter regarding layouts to make it more clear

 

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

Re: Arc Menu in blackberry


developer_aman_arora wrote:
try this code and study links that has been provided by peter regarding layouts to make it more clear

 


interesting how you suggest to study the links but write code that is different from what is told there.

calling super.sublayout followed by changing the layout is problematic, to say the least.

----------------------------------------------------------
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
Forums Advisor I
Posts: 501
Registered: ‎03-01-2013
My Device: BlackBerry Z10

Re: Arc Menu in blackberry

Hi

How do i set the position of buttons in arc menu?

Isn't it possible through setMargin?

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

Re: Arc Menu in blackberry

"How do i set the position of buttons in arc menu?"

Using setPositionChild() in sublayout() for your Manager

 

"Isn't it possible through setMargin?"

Not in the way you want to do it. 

 

Since you want the buttons to be in an arc, you are going to have to write your own Manager.  Links are given previously. 

Forums Advisor I
Posts: 501
Registered: ‎03-01-2013
My Device: BlackBerry Z10

Re: Arc Menu in blackberry

Hi
I have used setPositionChild() method but still the position of the buttons is not adjusted.

I always get the buttons below the main button.

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

Re: Arc Menu in blackberry

As noted previously, to do this effectively, you need to write your own Manager.  Do not extend HorizontalFieldmanager or VerticalFieldManager when doing this - both make assumptions about the location of Fields that are not true when you lay them out yourself.

 

I have given links previously to help you with doing this. 

 

Start simple, Just try to layout 3 LabelFields, one top left, one at 45 degrees, and one Bottom right.  Always in the same place, we can deal to adding and removing these later. 

 

Your Manager will have to calculate how much space is needed, and use this to set the extent (setExtent() method).  You need to position your children within that extent.

 

So create a very simple standalone sample, using your own Manager and 3 LabelFields.  If you can't get that working, then post the code for your Manager.  It should be less than 20 lines.  And post a screen shot of what you get.