Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

editfield weird height

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

like image 356
Ahmet Gulden Avatar asked Dec 19 '11 13:12

Ahmet Gulden


2 Answers

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

like image 111
Swati Avatar answered Oct 25 '22 23:10

Swati


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

like image 1
Eugen Martynov Avatar answered Oct 26 '22 00:10

Eugen Martynov