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


Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums on April 1st. BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com


Reply
New Developer
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

 

BlackBerry Development Advisor
Posts: 15,884
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
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.
New Developer
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?

 

BlackBerry Development Advisor
Posts: 15,884
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
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.
Highlighted
New Developer
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.