7
votes

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 hereenter image description here

2
can you please explain briefly? - Govindarao Kondala
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
can you please come here we will discuss more about this chat.stackoverflow.com/rooms/4014/… - Govindarao Kondala

2 Answers

1
votes

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

1
votes

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