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


Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.


Reply
Contributor
Posts: 21
Registered: ‎04-10-2013
My Device: All
My Carrier: 447920403580

Re: Get virtual keyboard height

I now have my program resizing perfectly when tilting, however, I can still not get the height of the keyboard. The only time Display.getHeight() returns the height minus the keyboard size is when the screen is tilted horizontally and the keyboard isn't even displayed. Can someone please help me with this? There must be some way to get the height of virtual keyboard. Thank you

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

Re: Get virtual keyboard height

As noted, I have never managed.  I will see if any thoughts pop up.

 

My understanding is that this is not a great thing to do:

"I can simply call setFont(font) in my fields' paint functions"

 

I believe this can be recursive - in that you call setFont, the Field thinks you have changed the Font, and so invalidates itself, which causes a layout and a repaint.  Which causes a setFont.....

Developer
Posts: 17,025
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Get virtual keyboard height

you can call setFont on the graphics object
----------------------------------------------------------
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
Highlighted
Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: Get virtual keyboard height

Oppss,  thought OP meant on the Field.  Sorry.

Contributor
Posts: 21
Registered: ‎04-10-2013
My Device: All
My Carrier: 447920403580

Re: Get virtual keyboard height

I've finally managed to get the height of the virtual keyboard. I only want the virtual keyboard when the screen is in portrait mode, so as soon as it's in portrait mode I load this screen:

 

public class StartScreen extends MainScreen
{
   private boolean alreadyRun;
	
   public StartScreen()
   {
      getScreen().getVirtualKeyboard().setVisibility(VirtualKeyboard.SHOW_FORCE);
   }
	
   protected void paint(Graphics graphics)
   {
      UiApplication.getUiApplication().invokeLater(new Runnable()
      {
         public void run()
         {
            if (!alreadyRun)
            {
               alreadyRun = true;
               NewScreen.KeyboardHeight = NewScreen.StartingScreenHeight - Display.getHeight();
               close();
            }
         }
      });
   }
}

 

I also had to override paint so I can update the changes:

 

static boolean UpdateDisplay;
protected void paint(Graphics graphics)
{
   if (UpdateDisplay
   {
      UpdateDisplay = false;
      UiApplication.getUiApplication().invokeLater(new Runnable()
      {
         public void run()
         {
            SetLayout();
            invalidate();
         }
      });
   }
   super.paint(graphics);
}

 It causes the screen to flicker when getting the keyboard height, so it's not a perfect solution, but it's the only solution I have. I can save the keyboard height using persistent storage, so the code will only need to run the first time the program is run in portrait mode.