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
BB_shi
Posts: 90
Registered: ‎03-15-2011
My Device: Blackberry 9800
My Carrier: developer
Accepted Solution

Screen is not scrolling when virtual keyboard is open by clicking on an edit field

Hi,

 

 

I searched and tried a lot but didn't get success.

 

There are three verticalfield managers in my screen.

 

1.)

vfmMain

= new VerticalFieldManager(Manager.USE_ALL_WIDTH | Manager.USE_ALL_HEIGHT | Manager.NO_VERTICAL_SCROLL) {

 

protectedvoidpaint(Graphics grphcs) {

 

if(imgBG != null){

grphcs.drawBitmap(0, 0,

imgBG.getWidth(), imgBG.getHeight(), imgBG, 0, 0);

}

super.paint(grphcs);

}

protectedvoid sublayout(int maxWidth, intmaxHeight) {

maxWidth = UIConstants.

SCREEN_WIDTH;

maxHeight = UIConstants.

SCREEN_HEIGHT;

 

super.sublayout(maxWidth, maxHeight);

 

super.setExtent(maxWidth, maxHeight);

}

};

 

2.)

vfmFieldNS

= new VerticalFieldManager(Manager.USE_ALL_WIDTH | Manager.USE_ALL_HEIGHT | NO_VERTICAL_SCROLL) {

 

protectedvoidpaint(Graphics grphcs) {

 

if (imgBGCoverInternetHome != null) {

grphcs.drawBitmap((UIConstants.

SCREEN_WIDTH - imgBGCoverInternetHome.getWidth()) / 2, 0, imgBGCoverInternetHome.getWidth(), imgBGCoverInternetHome.getHeight(), imgBGCoverInternetHome, 0, 0);

}

super.paint(grphcs);

}

protectedvoid sublayout(int maxWidth, intmaxHeight) {

maxWidth = UIConstants.

SCREEN_WIDTH;

maxHeight =

imgBGCoverInternetHome.getHeight()/* UIConstants.SCREEN_HEIGHT- (UIConstants.LABEL_HEIGHT + UIConstants.FOOTER_MENU_HEIGHT)*/;

 

super.sublayout(maxWidth, maxHeight);

 

super.setExtent(maxWidth, maxHeight);

 

}

};

 

3)

vfmScroll

= new VerticalFieldManager(USE_ALL_WIDTH | USE_ALL_HEIGHT | VERTICAL_SCROLL) {

 

protectedvoid sublayout(int maxWidth, intmaxHeight) {

maxWidth = UIConstants.

SCREEN_WIDTH;

maxHeight =

imgBGCoverInternetHome.getHeight()-imgButtonFocusBig.getHeight()/2/*UIConstants.SCREEN_HEIGHT - (UIConstants.LABEL_HEIGHT + (UIConstants.FOOTER_MENU_HEIGHT + VERTICAL_GAP))*/;

 

super.sublayout(maxWidth, maxHeight);

 

super.setExtent(maxWidth, maxHeight);

}

};

 

I am addidng all fields in scrollable manager that is vfmScroll.

 

 By clicking on edit field, virtual keyboard opens over the screen, edit field hides and screen does not scroll.

 

 

Please Help.

Thanks in advance.

 

 

 

 

 

 

Please use plain text.
Developer
peter_strange
Posts: 19,601
Registered: ‎07-14-2008
My Device: Not Specified

Re: Screen is not scrolling when virtual keyboard is open by clicking on an edit field

Can I suggest that you try your code using a standard VerticalFieldManager, make sure it works, then try to manipulate the layout of your Fields.

 

I recommend that you review this:

http://supportforums.blackberry.com/t5/Java-Development/How-to-Extend-Manager/ta-p/446749

and this:

http://supportforums.blackberry.com/t5/Java-Development/Create-a-custom-layout-manager-for-a-screen/...

 

Now you appear to be trying to make Managers that use all the screen, in which case I recommend you review this:

http://supportforums.blackberry.com/t5/Java-Development/MainScreen-explained/ta-p/606644

 

Anyway, this is dodgy code:

protected void sublayout(int maxWidth, int maxHeight) {
 maxWidth = UIConstants.SCREEN_WIDTH;
 maxHeight = UIConstants.SCREEN_HEIGHT;
 super.sublayout(maxWidth, maxHeight);
 super.setExtent(maxWidth, maxHeight);
}

You have asked the VFM to layout itself;f in a certain area.  And then you have told it how big it has to be - regardless of how big it determined that it had to be.

 

In addition, you are using this: UIConstants.SCREEN_HEIGHT;

 

Now when the Virtual keyboard is displayed the actual height of the screen is reduced by the size of the keyboard.  However you have told you Manager that it has the full Height, so it probably thinks it does not have to scroll. 

 

Sorry I don't have an immediate answer for you because I do not know what you are trying to do.  But I hope by reviewing the above and setting the height of the screen correctly you will overcome your problem.  If I was to suggest that you change one thing, it would be this:

 

protected void sublayout(int maxWidth, int maxHeight) {
 maxWidth = Math.max(UIConstants.SCREEN_WIDTH, maxWidth);;
 maxHeight = Math.max(UIConstants.SCREEN_HEIGHT, maxHeight);
 super.sublayout(maxWidth, maxHeight);

}

 

 

 

 

Please use plain text.
Developer
BB_shi
Posts: 90
Registered: ‎03-15-2011
My Device: Blackberry 9800
My Carrier: developer

Re: Screen is not scrolling when virtual keyboard is open by clicking on an edit field

Thanks for the reply Peter. Instead of UIConstants.SCREEN_HEIGHT, Now I am using Display.getHeight()-headerHeight-footerHeight. Since Display.getHeight() is getting calculated accordingly when virtual keyboard is open, so its working fine for me.
Please use plain text.
Trusted Contributor
ankitagrawal
Posts: 141
Registered: ‎02-15-2012
My Device: 9800
My Carrier: Airtel

Re: Screen is not scrolling when virtual keyboard is open by clicking on an edit field

This may also useful to me.

Please use plain text.