7

In my application i have 2 types of editfields. One of them behaves like single line editfield, the other behaves like multi-line editfield (editarea). In this screen i have one header, one editfield and one editarea. When i enter some text to editfield, it clips the text and cursor. But, when i enter some text to editarea which includes a tailed character(y,g,q,p) editareas height is changing and editfieldact normal. If i dont enter tailed characters stuation does not change.

Here is my editarea class:

public class EditAreaField extends HorizontalFieldManager{
    private net.rim.device.api.ui.component.EditField editArea;
    public EditAreaField (){
         // some code;
         editArea.setPadding(25, 10, 0, 10);    
    }
    public int getPreferredHeight() {
        int height = Math.max(editArea.getHeight(), textFont.getHeight());
        return height  + editArea.getPaddingTop();
    }
}

label1 -> editfield

label2 -> editarea

enter image description here enter image description here

CRUSADER
  • 5,486
  • 3
  • 28
  • 64
Ahmet Gulden
  • 2,063
  • 2
  • 15
  • 23
  • can you please explain briefly? – Govindarao Kondala Dec 28 '11 at 08:14
  • well i did explain in the question actually. In the left image you can see, there is a clipping problem half of the cursor is over the first character, half of it is at the last character. If you type some character tailed the clipping error is no more. – Ahmet Gulden Dec 28 '11 at 08:43
  • can you please come here we will discuss more about this http://chat.stackoverflow.com/rooms/4014/knowledge-sharing-center-for-blackberry-and-java – Govindarao Kondala Dec 28 '11 at 08:44

2 Answers2

1

this is because you are making the size to change by using

    int height = Math.max(editArea.getHeight(), textFont.getHeight());

instead of this try to give some fixed height. for example

    height= Graphics.getScreenHeight()/5;

or you can also use setExtent inside the sublayout method of the manager

     protected void sublayout(int maxWidth, int maxHeight)
            {
                layoutChild(_editField, _editField.getPreferredWidth(), _editField.getPreferredHeight());
                setPositionChild(_editField, xpos,ypos);
                setExtent(preferredHeight,preferredWidth);
            }

I think it will work. Please let me know

Swati
  • 1,179
  • 9
  • 28
  • editfield is fixed size but editarea should not be fixed because we dont know how many characters will user enter. Additionally i set extent inside the sublayout method by overriding it as you said. it is weird editarea's height is 38 when initialized, when user put tailed characters it is changing to 39. There is the problem i think. – Ahmet Gulden Dec 20 '11 at 22:29
1

About the cursor painting - you did override drawFocus or/and onFocus or/and onUnfocus and don't repaint properly sometime.

Eugen Martynov
  • 19,888
  • 10
  • 61
  • 114
  • i overrode onFocus and onUnfocus. the custom component that i added the same screen in the images are behaving differently. If there is a problem on left image, the problem has to remain at the right image. the source of the problem is the editarea component i think but i am not able to solve it. – Ahmet Gulden Dec 31 '11 at 11:31