Hi all,
I'm TRYING to get EditFields working correctly side-by-side in a FlowFieldManager. I have them all aligning as I want, but their edit behavior is broken.
Using the roller ball, you can go from field to field, but the cursor never iterates thru the characters in each field, allowing one to correctly edit them.
This same code, using a HorizontalFieldManager works, BUT, I can not get fields on a second line.
Here's a screenshot of what it looks like:
My goal is to be able to properly edit these fields, while maintaining the correct layout.
Here's my class code.
Any and all help is greatly appreciated.
Code:
package com.wcs.blackberry;
import net.rim.device.api.system.Characters;
import net.rim.device.api.ui.Field;
import net.rim.device.api.ui.MenuItem;
import net.rim.device.api.ui.UiApplication;
import net.rim.device.api.ui.component.EditField;
import net.rim.device.api.ui.container.FlowFieldManager;
import net.rim.device.api.ui.container.MainScreen;
import com.wcs.blackberry.util.BBLogger;
// The Sandbox application is a Blackberry Pearl testbed.
public class Sandbox extends UiApplication
{
public static void main(String[] args)
{
Sandbox theApp = new Sandbox();
theApp.enterEventDispatcher();
}
public Sandbox()
{
MainScreen screen = new SandboxScreen();
pushScreen(screen);
}
}
final class SandboxScreen extends MainScreen
{
public SandboxScreen()
{
super(MainScreen.DEFAULT_MENU | MainScreen.DEFAULT_CLOSE);
MenuItem menuItem = BBLogger.getShowLogMenuItem();
addMenuItem(menuItem);
FlowFieldManager ffm = new FlowFieldManager(
FlowFieldManager.HORIZONTAL_SCROLL | FlowFieldManager.VERTICAL_SCROLL);
ffm.add(new FixedWidthField("abc"));
ffm.add(new FixedWidthField("def"));
ffm.add(new FixedWidthField("ghi"));
ffm.add(new FixedWidthField("jkl"));
add(ffm);
}
public class FixedWidthField extends EditField
{
public FixedWidthField(String string)
{
super("", string, 10, Field.FOCUSABLE);
}
public int getPreferredWidth()
{
return 80;
}
public void layout(int maxWidth, int maxHeight)
{
super.layout(getPreferredWidth(), super.getPreferredHeight());
setExtent(getPreferredWidth(), super.getPreferredHeight());
}
}
public boolean onClose()
{
System.exit(0);
return true;
}
public boolean keyChar(char key, int status, int time)
{
switch (key)
{
case Characters.ESCAPE:
onClose();
return true;
}
return super.keyChar(key, status, time);
}
}