Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
New Contributor
user107
Posts: 8
Registered: ‎03-24-2012
My Device: Developer
My Carrier: 9800

Edit field wrapped text preventing code disables vertical scroll of main screen

Hello all,

I am having an custom edit field  with image which i am setting in its paint background method.
My custom edit field class extends horizontal scroll as i need it. but still input is not in one line while i am setting property EditField.No_Newline.

 

alternatively, I added some piece of code in my paint to do so...
but its updating my MainScreen scroll ......what to do pls help...

 

EditField ef = (EditField)getField(0);
String entireText = ef.getText();


boolean longText = false;
String textToDraw = "";
font = getFont();
int availableWidth = width - totalHorizontalEmptySpace;
if (font.getAdvance(entireText) <= availableWidth)
{
textToDraw = entireText;
}
else
{
int endIndex = entireText.length();
for (int beginIndex = 1; beginIndex < endIndex; beginIndex++)
{
textToDraw = entireText.substring(beginIndex);
if (font.getAdvance(textToDraw) <= availableWidth)
{
longText = true;
break;
}
}
}


if (longText == true)
{
// Force the edit field display only the truncated text
ef.setText(textToDraw);


// Now let the components draw themselves
super.paint(graphics);


// Return the text field its original text
ef.setText(entireText);
}
else
{
super.paint(graphics);
}


 

Please use plain text.
Developer
simon_hain
Posts: 16,102
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Edit field wrapped text preventing code disables vertical scroll of main screen

maybe this helps you out?
http://supportforums.blackberry.com/t5/Java-Development/Sample-Code-Scrollable-one-line-text-input-f...
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Please use plain text.
New Contributor
user107
Posts: 8
Registered: ‎03-24-2012
My Device: Developer
My Carrier: 9800

Re: Edit field wrapped text preventing code disables vertical scroll of main screen

sorry, But i don't need like this..
i need all the text in horizontal line...
Thanks...
Please use plain text.
Developer
pankajace12
Posts: 194
Registered: ‎04-30-2011
My Device: Software
My Carrier: Airtel

Re: Edit field wrapped text preventing code disables vertical scroll of main screen

HI,

 

VerticalFieldManager vfm = new VerticalFieldManager(this.HORIZONTAL_SCROLL | USE_ALL_WIDTH | USE_ALL_HEIGHT);

 

EditField e = new EditField("Username","");

 

vfm.add(e);

 

if you do use this code. Then the text will be in single line. Henceforth, you customize this as your need.

 

Press Like, if you find this code is helpful to you.

Please use plain text.