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 Developer
BB21
Posts: 11
Registered: ‎01-08-2009
My Device: Not Specified
Accepted Solution

A part of the cursor remains in the custom field

Hello,guys!

 

I have a problem.

 

In custom field that extends EditField, I want to draw in the text and the image and to draw to an appropriate position in the cursor. Then, it was thought that it only had to calculate the advance of the font and the width of the image in the paint method, to display the text and the image, and to make focus similar, and tried.However, drawing of the cursor doesn't go well. When the cursor moves from the right to the left, a part of the cursor at the position immediately before remains. 

 

Is there a good solution?

 

JDE Component Package : 4.6.0

 

Please use plain text.
Administrator
MSohm
Posts: 14,412
Registered: ‎07-09-2008
My Device: BlackBerry Z30, BlackBerry PlayBook
My Carrier: Bell

Re: A part of the cursor remains in the custom field

To "remove" the cursor, you could draw it in its previous location using the background colour for your field.  This could "erase" the cursor before you draw text in its previous location.

 

Or you could call the clear method on the Graphics object to clear everything.  However, this means you have to redraw the entire field.

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Please use plain text.
New Developer
BB21
Posts: 11
Registered: ‎01-08-2009
My Device: Not Specified

Re: A part of the cursor remains in the custom field

Thank you for the reply, Mark. 

 

I had the Graphics.clear() method processed first in the paint() method. However, a part of the cursor remained as it was. Then, the another way was tested. It is to call the invalidate() method in the drawFocus() method at the end. It seems to go well in this method. However, the paint() method and the drawFocus() method are called when almost permanent. 

 

Will this be a correct solution? Moreover, why does not the Graphics.clear() method clear the drawing area?

 

Please use plain text.
Administrator
MSohm
Posts: 14,412
Registered: ‎07-09-2008
My Device: BlackBerry Z30, BlackBerry PlayBook
My Carrier: Bell

Re: A part of the cursor remains in the custom field

This could relate to the size of the graphics object you are working with.  A field can invalidate part of itself, meaning only that section is redrawn.  Anything outside of this region would be left alone and not cleared by a call to Graphics.clear.

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Please use plain text.
New Developer
BB21
Posts: 11
Registered: ‎01-08-2009
My Device: Not Specified

Re: A part of the cursor remains in the custom field

I solved by myself.

 

"FocusChangeListener" is mounted with EditField. And, "invalidate()" was called in the "focusChanged()" method.

This became a great result for me.

 

Thank you.

Please use plain text.