If you are using Internet Explorer, please remove blackberry.com from your compatibility view settings.

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
Contributor
obo-kb
Posts: 30
Registered: ‎03-24-2011
My Device: 9800
My Carrier: sfr

BasicEditField problem : cursor is over the border

Hello,

 

I build an EditField with the following method :

 

 

BasicEditField searchField = new BasicEditField("", "", 30, TextField.NO_NEWLINE); 
searchField.setBorder(VISUAL_STATE_NORMAL, BorderFactory.createRoundedBorder(new XYEdges(7,7,7,7)));

 

 

The problem is that the cursor is displayed over the border.

How can I do to specify the cursor to be centered between the upper and lower border and takes a given padding from left and right ?

 

Thanks in advance.

Please use plain text.
Developer
arkadyz
Posts: 2,268
Registered: ‎07-08-2009
My Device: various
My Carrier: various

Re: BasicEditField problem : cursor is over the border

I've seen a few border problems with (Basic)EditField reported here on the forum. Generally, the workaround I suggest is this: have your field in a separate (dedicated) manager and setBorder on the manager rather than the field. I have a feeling that BasicEditField implementation has a bug displaying the cursor - apparently they forgot to take Border into account while calculating its position.

 

By the way, padding for BasicEditField is also broken, so, again, that functionality is better delegated to a manager as well. And, while you are at it, check the correctness of setBackground.

 

Good luck!

----------------------------------------------------------
please click 'Accept Solution' on posts that provide the solution to the question you've posted. Don't say "Thanks", press 'Like' button instead!
Please use plain text.
Contributor
obo-kb
Posts: 30
Registered: ‎03-24-2011
My Device: 9800
My Carrier: sfr

Re: BasicEditField problem : cursor is over the border

Something like this ?

 

 

HorizontalFieldManager searchManager = new HorizontalFieldManager(Field.FIELD_HCENTER | Field.USE_ALL_WIDTH);
BasicEditField searchField = new BasicEditField("", "", 30, Field.FIELD_HCENTER | TextField.NO_NEWLINE); 
searchManager.setBorder(VISUAL_STATE_NORMAL, BorderFactory.createRoundedBorder(new XYEdges(5,5,5,5)));
searchManager.setMargin(10, 10, 10, 10);
searchManager.setPadding(5,5,5,5);
searchManager.add(searchField);

 

But the behaviour is the same : the cursor is still displayed over the border.

 

Please use plain text.
Developer
arkadyz
Posts: 2,268
Registered: ‎07-08-2009
My Device: various
My Carrier: various

Re: BasicEditField problem : cursor is over the border

Hmmm, that's weird...

 

You can take another step and layout the field and paint the border manually. If you take a look at the code below, you'll see an example of how it can be done:

OneLineTextField - comment #3

Pay attention at layoutChild and setPositionChild calls - they should give you ideas on how to manage the screen on a lower level.

In fact, take some time to read the whole article - it seems that you might really benefit from it. The border there is rectangular with settable thickness and different top, right, bottom and left border shades, but you may throw out all those drawLine calls and replace them with one drawRoundRect.

----------------------------------------------------------
please click 'Accept Solution' on posts that provide the solution to the question you've posted. Don't say "Thanks", press 'Like' button instead!
Please use plain text.