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
RileyGB
Posts: 284
Registered: ‎08-06-2010
My Device: Z10
Accepted Solution

Make a VFM completely visible upon focus.

I have a VerticalFieldManager that has a NullField in it to allow focusing. I'm basically replicating a ListField, but not using one as it has poor performance in my app.

 

I'm trying to figure out how to implement the following:

 

When the null field gains focus, make the entire VFM Visible.

 

Would anyone have an idea of how I can accomplish this? 

 

Thanks!

 

 

 



Follow me on twitter @RileyGB - https://twitter.com/RileyGB
View my BB10 OpenSource projects - https://github.com/RileyGB/BlackBerry10-Samples
Please use plain text.
Developer
mreed
Posts: 1,041
Registered: ‎07-16-2008
My Device: ಠ_ಠ

Re: Make a VFM completely visible upon focus.

In onFocus() you can call updateLayout() and set the desired height in your sublayout() method with setExtent().

Please use plain text.
Developer
arkadyz
Posts: 2,268
Registered: ‎07-08-2009
My Device: various
My Carrier: various

Re: Make a VFM completely visible upon focus.

This has nothing to do with updateLayout() or anything like that: the system auto-scrolls on focus changes to the rectangle returned by getFocusRect. Here is the way to approach the problem:

Re: List of HorizontalFieldManager with scrolling focus problem

----------------------------------------------------------
please click 'Accept Solution' on posts that provide the solution to the question you've posted. Don't say "Thanks", press 'Like' button instead!
Please use plain text.
Developer
RileyGB
Posts: 284
Registered: ‎08-06-2010
My Device: Z10

Re: Make a VFM completely visible upon focus.

I was able to accomplish it with updateLayout. Thanks for the suggestions. Below is a sample of my code

 

boolean moveUp = false;

NullField nullField = new NullField(FOCUSABLE | Field.FIELD_BOTTOM) {
			protected void onFocus(int direction) {
				super.onFocus(direction);	
				if(direction == 1)
					moveUp = false;
				else
					moveUp = true;
				
				updateLayout();
			}	
			
			protected void onUnfocus() {
				super.onUnfocus();
			}
			
			public void layout(int width, int height)
			   {
				if(this.isFocus() && !moveUp) {
					this.setPosition(0, myVFM.getHeight());
			        super.setExtent(1,1);
				}
				else if(this.isFocus() && moveUp) {
				   this.setPosition(0, 0);
				   super.setExtent(1,myVFM.getHeight());
				}
				else {
					super.setExtent(1,1);
				}
			   }
		};

 



Follow me on twitter @RileyGB - https://twitter.com/RileyGB
View my BB10 OpenSource projects - https://github.com/RileyGB/BlackBerry10-Samples
Please use plain text.
Developer
arkadyz
Posts: 2,268
Registered: ‎07-08-2009
My Device: various
My Carrier: various

Re: Make a VFM completely visible upon focus.


searingmedia wrote:

I was able to accomplish it with updateLayout. Thanks for the suggestions. Below is a sample of my code

 


I hope you realize what you've done: you move your NullField within the containing manager on each onFocus. This depends on the Manager to first setPositionChild then layoutChild. A VFM seemingly does exactly that - but if it changes the order in the future, your program will stop working the way you want.

 

I heartily recommend trying the other solution - it does not depend on the implementation details of other classes.

 

Also you don't want that setExtent(1, 1) - the default (0, 0) is just fine. NullField should be invisible.

----------------------------------------------------------
please click 'Accept Solution' on posts that provide the solution to the question you've posted. Don't say "Thanks", press 'Like' button instead!
Please use plain text.