haferblues
haferblues

Reputation: 2253

EditField is cut off if margin is set on Torch

As you can see from the SSCCE I do setBanner() and setStatus() and then only add an EditField in between.

Now on a Torch, if you enter a lot of characters in the EditField until its height exceeds the area between banner and status, the last text line is overlapped by the status bar. See screenshot: enter image description here

This only happens, when I set a margin for the EditField, but obviously I need this margin. Seems to be a Torch bug, since it works on other BB devices. But does anyone maybe know a workaround?

Here is the SSCCE:

import net.rim.device.api.browser.field2.BrowserField;
import net.rim.device.api.ui.Color;
import net.rim.device.api.ui.UiApplication;
import net.rim.device.api.ui.component.ButtonField;
import net.rim.device.api.ui.component.EditField;
import net.rim.device.api.ui.container.HorizontalFieldManager;
import net.rim.device.api.ui.container.MainScreen;
import net.rim.device.api.ui.decor.BackgroundFactory;

public class CutOff extends UiApplication implements Runnable
{
    /**
     * @param args
     */
    public static void main(final String[] args)
    {
        final CutOff bt = new CutOff();
        bt.invokeLater(bt);
        bt.enterEventDispatcher();

    }

    public void run()
    {
        final MainScreen s = new MainScreen();
        //header
        final HorizontalFieldManager head = new HorizontalFieldManager();
        head.add(new ButtonField("header"));
        s.setBanner(head);

        //footer
        final HorizontalFieldManager hf = new HorizontalFieldManager();
        hf.setBackground(BackgroundFactory.createSolidBackground(Color.RED));
        hf.add(new ButtonField("test"));
        final EditField f = new EditField();
        f.setMargin(10, 10, 10, 10);
        s.add(f);
        s.setStatus(hf);

        UiApplication.getUiApplication().pushScreen(s);
    }

}

Thanks

Upvotes: 2

Views: 78

Answers (1)

Rince Thomas
Rince Thomas

Reputation: 4158

Try this -

Add your EditField to a HorizontalFieldManager.

     final MainScreen s = new MainScreen();
    //header
    final HorizontalFieldManager head = new HorizontalFieldManager();
    head.add(new ButtonField("header"));
    s.setBanner(head);

    //footer
    final HorizontalFieldManager hf = new HorizontalFieldManager();
    hf.setBackground(BackgroundFactory.createSolidBackground(Color.RED));
    hf.add(new ButtonField("test"));
    HorizontalFieldManager h=new HorizontalFieldManager(HorizontalFieldManager.VERTICAL_SCROLL);
    final EditField f = new EditField();
    f.setMargin(10, 10, 10, 10);
    h.add(f);
    s.add(h);
    s.setStatus(hf);

    UiApplication.getUiApplication().pushScreen(s);

Upvotes: 2

Related Questions