hi superdirt,
Thanks for the reply
Here im posting the code where in the text gets printed from the right but it is scrolling to the left and it is not changing the position of the cursor,im setting the position of the cursor still no change
class CustomEditField extends Manager
{
private int _fieldHeight = 0;
private int _fieldWidth = 0;
private long _alignment;
private Font _font = Font.getDefault();
private AlignableEditField _editField;
public CustomEditField(String initialValue, int maxNumChars, long style)
{
super(NO_VERTICAL_SCROLL | NO_VERTICAL_SCROLLBAR);
_alignment = (style & BasicEditField.FIELD_HALIGN_MASK & BasicEditField.FIELD_TRAILING);
_editField = new AlignableEditField(null, initialValue, maxNumChars, style)
{
protected void onFocus(int direction)
{
setCursorPosition(0);
};
};
add(_editField);
}
protected void paint(Graphics g) {
super.paint(g);
}
public int getPreferredWidth() {
return _fieldWidth;
}
public int getPreferredHeight() {
return _font.getHeight();
}
public String getText() {
return _editField.getText();
}
public void setFont(Font value) {
_font = value;
_editField.setFont(_font);
}
protected void sublayout(int width, int height) {
if (_fieldWidth == 0) {
_fieldHeight = height;
_fieldWidth = width;
setExtent(width, _fieldHeight);
}
int textWidth = _editField.getPreferredWidth();
layoutChild(_editField, textWidth, _fieldHeight);
if (_alignment == FIELD_RIGHT)
{
setPositionChild(_editField, getPreferredWidth() - textWidth-10, 0);
}
else if (_alignment == FIELD_HCENTER)
{
setPositionChild(_editField,
(getPreferredWidth() - textWidth) / 2, 0);
}
else
{
// FIELD_LEFT
setPositionChild(_editField, 0, 0);
}
}
private void layoutEditField() {
sublayout(_fieldWidth, _fieldHeight);
}
private class AlignableEditField extends BasicEditField
{
public AlignableEditField(String label, String initialValue,int maxNumChars, long style)
{
super(label, initialValue, maxNumChars, style);
}
public int getPreferredWidth()
{
return Math.max(_font.getAdvance(getText()), _font.getAdvance('0'))+ _font.getAdvance(' ');
}
protected boolean keyChar(char key, int status, int time)
{
boolean result = super.keyChar(key, status, time);
layoutEditField();
return result;
}
/* protected void onFocus(int direction)
{
setCursorPosition(0);
super.onFocus(direction);
}*/
}
}
}
iam unable to understand what are the changes that need to b done.
any help...
Thanks in advance.