views:

2446

answers:

2

I want to create a RichTextField at the bottom half of the screen, while I paint my own custom graphics at the top half of the screen. Is that possible in BlackBerry? It tried defining a LayoutManager and trying to position the RichTextField at the bottom of the screen but the RichTextField, scroll through the entire screen. This is the code for the LayoutManager(). Is it the right way or is there any other way to do what I have mentioned above.

class LayoutManager extends Manager 
{

  public LayoutManager() 
  { 
    //construct a manager with vertical scrolling    
    super(VERTICAL_SCROLL);
  }

  //overwrite the nextFocus method for custom navigation  
  protected int nextFocus(int direction, boolean alt)  
  {
        return super.nextFocus(direction, alt);
  }

  protected void sublayout(int width, int height) 
  {
    Field field;
    //get total number of fields within this manager
    int numberOfFields = getFieldCount();     
    int x = 0;
    int y = 0;
    System.out.println("******** Fields: " + numberOfFields + " W/H: " + width + " / " + height );
    for(int i = 0;i < numberOfFields;i++) {
      field = getField(i);      //get the field
      x = 20;
      y = 80;
      System.out.println("******** X/Y: " + x + " / " + y);
      setPositionChild(field, x, y);  //set the position for the field
      layoutChild(field, width, y);  //lay out the field
    }
    setPosition(0, 80);
    setExtent(width, 80);

  }

  public int getPreferredWidth() 
  {
   return 160;
  }

  public int getPreferredHeight() 
  {
    int height= 0;
    int numberOfFields= getFieldCount();

    for(int i= 0; i < numberOfFields; i++) 
    {
        height += getField(i).getPreferredHeight();
    }
    return 160;
  }
}
A: 

Hi, you can unset focus from your RichTextField. And also keep in mind that you can control focus using null fields. I've recentlyy had battles for scrolling with my custom list field. You can check my post, it might be helpful.

nixau
If you're particulary interested in focused RichTextField, you can derive from it and dismiss default implementation of its drawFocus method.
nixau
Will the content of the RichTextField scroll within itself without the RichTextField moving position in the screen?
Ram
It shouldn't unless it gets focused again.
nixau
+4  A: 
Max Gontar
Thanks coldice, this was what I wanted
Ram
You're welcome!
Max Gontar
One more thing, is there a way I could set the background and font colors for the RichTextField?
Ram
sure, see update
Max Gontar
sorry, moved to http://stackoverflow.com/questions/1431189/setting-background-and-font-colors-for-richtextfield-textfield/1431785#1431785
Max Gontar