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
New Developer
Sparkletron
Posts: 8
Registered: ‎08-03-2009
My Device: Not Specified

Rendering issues using VerticalFieldManager and AutoTextEditField with background gradients

I have a MainScreen with a VerticalFieldManager managing an AutoTextEditField. Both the manager and the field have background gradients. I override the manager's paint method to ensure that the manager's vertical dimensions do not take up their typical value of Integer.MAX_VALUE / 2. Instead, I limit the manager's vertical dimensions to the display height. If I do not do this, then the background gradient does not render properly, as it stretches the gradient to fill up all the available vertical space, which in the case of Integer.MAX_VALUE / 2 is considerable. Anyway, here's what it looks like...

 



It works as expected and all is well. Now I begin to enter text...

 

 

...and everything continues to work as expected until I use up all the available display height...

 

 

Here we see the rendering issue manifest itself. It appears as an ever-expanding block of white at the bottom of the screen. If I keep typing...

 

 

...it gets worse and the position of the new line continues to climb back up until it reaches the top and vanishes altogether. If I scroll up and then back down, the rendering issues vanish and I see...

 

 

So my question is: how do I prevent these rendering issues while retaining the background gradient behavior?

 

I've tried overriding various events to add invalidate and force a repaint but none of this has any effect. Perhaps I'm not overriding the correct event?

 

Here's code to demonstrate the rendering issue. The first part is just a standard application shell...

 

 

package myPackage; import myPackage.screens.MyScreen; import net.rim.device.api.ui.UiApplication; public class RenderingIssue extends UiApplication { MyScreen myScreen; public static void main(String[] args) { RenderingIssue elvisMobile = new RenderingIssue(); elvisMobile.enterEventDispatcher(); } public RenderingIssue() { // UI. myScreen = new MyScreen(); // pushScreen(myScreen); } }

 

 

And here's the screen with the manager and field...

 

 

package myPackage.screens; import net.rim.device.api.ui.Color; import net.rim.device.api.ui.XYEdges; import net.rim.device.api.ui.component.AutoTextEditField; import net.rim.device.api.ui.container.MainScreen; import net.rim.device.api.ui.container.VerticalFieldManager; import net.rim.device.api.ui.decor.Background; import net.rim.device.api.ui.decor.BackgroundFactory; import net.rim.device.api.ui.decor.Border; import net.rim.device.api.ui.decor.BorderFactory; public class MyScreen extends MainScreen { static final Background managerBackground = BackgroundFactory.createLinearGradientBackground(Color.LIGHTSKYBLUE, Color.LIGHTSKYBLUE, Color.LIGHTGRAY, Color.LIGHTGRAY); static final Background fieldBackground = BackgroundFactory.createLinearGradientBackground(0x00ffff99, Color.WHITE, Color.WHITE, 0x00ffff99); AutoTextEditField autoTextEditField; VerticalFieldManager verticalFieldManager = new VerticalFieldManager(VerticalFieldManager.VERTICAL_SCROLL | VerticalFieldManager.VERTICAL_SCROLLBAR) { // Use all available screen real estate. // Note that the screen may have a title; don't count that as available space. protected void sublayout(int width, int height) { if (getScreen().getWidth() != 0 && getScreen().getHeight() != 0) { width = getScreen().getWidth() - getManager().getLeft(); height = getScreen().getHeight() - getManager().getTop(); } else { width -= getManager().getLeft(); height -= getManager().getTop(); } super.sublayout(width, height); setExtent(width, height); } }; public MyScreen() { super(); // Update autoTextEditField. autoTextEditField = new AutoTextEditField("", ""); autoTextEditField.setMargin(12, 12, 12, 12); autoTextEditField.setPadding(12, 12, 12, 12); autoTextEditField.setBackground(fieldBackground); autoTextEditField.setBorder(BorderFactory.createRoundedBorder(new XYEdges(3, 3, 3, 3), Color.BLACK, Border.STYLE_SOLID)); // Update verticalFieldManager. verticalFieldManager.setBackground(managerBackground); verticalFieldManager.add(autoTextEditField); // add(verticalFieldManager); } }

 

 

 

Please use plain text.
Developer
haagmm
Posts: 178
Registered: ‎07-29-2008
My Device: Not Specified

Re: Rendering issues using VerticalFieldManager and AutoTextEditField with background gradients

.

I guess this kidna depends on what you plan on using the VerticalFieldManager for later.

 

The imple solution i belive would be to remove you sublayout and use "USE_ALL_HEIGHT" in the constructor.

 

The bigger issue is this.  When your contents are LARGER than the screen you need to also call setVirtualExtent() if your doing manaual image mucking.  The issue i belive is that the scroll is being passed UP to the screen's deligate manager.  what you want to do is call

getVirtualHeight() and getVirtualWidth() after you call super, and set them with setVirtualExtent() after you call setExtent()

 

 

Please use plain text.
New Developer
Sparkletron
Posts: 8
Registered: ‎08-03-2009
My Device: Not Specified

Re: Rendering issues using VerticalFieldManager and AutoTextEditField with background gradients

Thanks for responding.

 

USE_ALL_HEIGHT is where I began this journey. It results in the gradient not being rendered properly, stretching the gradient to Integer.MAX_VALUE / 2, which is considerably more than the display height. Overriding setPreferredHeight() doesn't help, and it's not possible to override getHeight() or getVirtualHeight().

 

I tried your suggestion of calling setVirtualExtent() after I call setExtent(). It doesn't resolve the issue. Same result.

 

At this point I could really use the source code to VerticalFieldManager, so I can see exactly what it's doing. Coming from standard J2SE, I find I really miss not being able to look beneath the hood.

Please use plain text.
Developer
haagmm
Posts: 178
Registered: ‎07-29-2008
My Device: Not Specified

Re: Rendering issues using VerticalFieldManager and AutoTextEditField with background gradients

i agree.  I was just sitting here tracing the implimentation of updateLayout().

 

I'm sorry i have no good advice here, perhaps try using a full screen and not a main screen and making the delage manager not scroll.

Please use plain text.
New Member
gmc14
Posts: 1
Registered: ‎04-14-2010
My Device: 8900
My Carrier: Rogers

Re: Rendering issues using VerticalFieldManager and AutoTextEditField with background gradients

"Main screen objects contain a title section, a separator element, and a main scrollable section"

You just need need to use MainScreen.getMainManager()and set the background on that manager. 

Cheers!

Please use plain text.