I have created a CustomTextField which scrolls itself towards left when i type text which are extra than the width of the TextField for which a HorizonalFieldManager is used But now the problem is if i Right click with my mouse and scroll it it goes on to inadequate length but does not stop to the last word i type What is the problem here ?? Is it a bug
I just need that to disable HorizontalScrolling when it reaches the last word It should be able to scroll just between the start and end of last word in word
Check out the code
import net.rim.device.api.ui.Color;
import net.rim.device.api.ui.Field;
import net.rim.device.api.ui.FocusChangeListener;
import net.rim.device.api.ui.Graphics;
import net.rim.device.api.ui.Manager;
import net.rim.device.api.ui.XYEdges;
import net.rim.device.api.ui.XYRect;
import net.rim.device.api.ui.component.BasicEditField;
import net.rim.device.api.ui.container.HorizontalFieldManager;
import net.rim.device.api.ui.container.VerticalFieldManager;
import net.rim.device.api.ui.decor.Border;
import net.rim.device.api.ui.decor.BorderFactory;
public class CustomTextField extends VerticalFieldManager {
private int textWidth=0;
private int textHeight=0;
private BasicEditField basicEditField;
private HorizontalFieldManager hfm;
//Border border;
public CustomTextField(int width,int height) {
super();
textWidth=width;
textHeight=height;
//border=BorderFactory.createSimpleBorder(new XYEdges(1, 1, 1, 1));
hfm=new HorizontalFieldManager(Manager.HORIZONTAL_SCROLL){
protected void sublayout(int maxWidth, int maxHeight) {
super.sublayout(maxWidth, maxHeight);
setExtent(textWidth, textHeight);
}
};
basicEditField=new BasicEditField("","",200,BasicEditField.NO_NEWLINE);
//basicEditField.setBorder(border);
hfm.add(basicEditField);
add(hfm);
}
protected void sublayout(int maxWidth, int maxHeight) {
super.sublayout(textWidth, textHeight);
setExtent(textWidth, textHeight);
}
protected void paint(Graphics graphics) {
super.paint(graphics);
graphics.setColor(Color.BLACK);
graphics.drawRect(0,0, textWidth, textHeight);
}
}
i have initialised it as
CustomTextField textField=new CustomTextField(200, 20);
add(textField);
I feel the need of Scroll(is Scrolling Function) for HorizontalFieldManager ... but have not yet came up to solution yet Please help