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
Posts: 11
Registered: ‎12-19-2008
My Device: Not Specified

CustomEditfield not getting the focus

Hello all,

 

I have implemented Custom Editfield control.

 

The requirement is to have background color for Editfield. So, I used paint method to color the background of the Editfield. Its working fine, but the problem is the custom Editcontrol is not getting the focus.

 

Can someone please help me, how to get the focus in Custom Editfield ?

 

Thanks in advance,

--Premal

Developer
Posts: 16,999
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: CustomEditfield not getting the focus

are you sure about it not getting the focus? eventually you implemented paint in a way that hinders the field to paint the focus.
which field class did you extend?
----------------------------------------------------------
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
Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: CustomEditfield not getting the focus

Agree with everything Simon has said, just wanted to add make sure:

a) you not overridden isFocusable() to return false in your CustomEditfield or

b) supplied Field.NON_FOCUSABLE as a style in the constructor.

New Developer
Posts: 11
Registered: ‎12-19-2008
My Device: Not Specified

Re: CustomEditfield not getting the focus

Hello Guys,

 

First of all, thank you very much for your reply and efforts.

 

I am extending EditField class and I have also overridden isFocusable() method which returns true.

Here is my constructor and paint method.

 

Can you please tell me what is wrong here ?

 

public CustomEditField(String pText)      

{

super("", pText);

}

 

public void paint(Graphics g)

{

        g.getBackgroundColor();

        g.setBackgroundColor(bgColor);

        g.clear();

        g.getColor();

        g.setColor(color);

        super.paint(g);                                    

}

 

Thanks in advance,

--Premal

Developer
Posts: 16,999
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: CustomEditfield not getting the focus

graphics.setBackgroundColor(backgroundcolor);
graphics.clear();
super.paint(graphics);

this should be sufficient. you don't have to overwrite any other methods as the editfield is focusable by default.
----------------------------------------------------------
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
New Developer
Posts: 11
Registered: ‎12-19-2008
My Device: Not Specified

Re: CustomEditfield not getting the focus

Thanks for your reply. 

 

Now i am getting the focus, but not the caret. I can type the text in edit field. 

 

How to get the default caret (“|”) in my custom edit field ?Do I need to take any special care for caret? 

 

Thanks in advance,--Premal 

 

 

Highlighted
BlackBerry Development Advisor
Posts: 15,753
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: CustomEditfield not getting the focus

Have you tried changing your colour scheme as a test?  The cursor may be there but drawn in a similar colour so it's not visible.
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