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

Posts: 141
Registered: ‎08-06-2008
My Device: Not Specified

text input in popupScreen

Hi all,


Merry Christmas!


I have problem in PopupScreen with EditField and other fields.


I created popup screen and added couple of text edit field but I can not type.

Typing is not showing and not working at all.


Here is the code:

private void popupMenu() { DialogFieldManager manager = new DialogFieldManager() { protected void sublayout(int width, int height) { super.sublayout(Display.getWidth()-40,Display.getHeight()-42); setExtent(Display.getWidth()-40, Display.getHeight()-42); setPosition(0,0); } }; // creating popup screen _popupMenu = new PopupScreen(manager, DEFAULT_CLOSE|PopupScreen.NO_VERTICAL_SCROLL|FIELD_HCENTER); //------------------------- VerticalFieldManager vHldmgr = new VerticalFieldManager(VerticalFieldManager.NO_HORIZONTAL_SCROLL | VerticalFieldManager.USE_ALL_WIDTH |VerticalFieldManager.FIELD_LEFT |VerticalFieldManager.FIELD_VCENTER| VerticalFieldManager.NO_HORIZONTAL_SCROLLBAR) { protected void paint(Graphics g) { if (g.getBackgroundColor() != 3098850) { g.setBackgroundColor(0xf9f8f5); g.clear(); } super.paint(g); } protected void sublayout(int maxWidth, int maxHeight) { super.sublayout(Display.getWidth()-40, this.getHeight()+10); setExtent(Display.getWidth()-40, this.getHeight()+10); } }; LabelField nameLabel = new LabelField("Friend's Name: ", LabelField.FIELD_LEFT|LabelField.VCENTER) { public void paint(Graphics g) { g.setColor(0x000000); this.setFont(f12b); super.paint(g); } protected void layout(int maxWidth, int maxHeight) { super.layout(Display.getWidth()-40, this.getHeight()+4); setExtent(Display.getWidth()-40, this.getHeight()+4); } }; friendsName = new AutoTextEditField ("", "Enter your friend's name.", 60, AutoTextEditField.FIELD_HCENTER| EditField.FIELD_BOTTOM|EditField.FOCUSABLE) { public void onFocus(int direction){ if(this.getText().equals("Enter your friend's name.")) this.setText(""); super.onFocus(direction); } public void onUnfocus(){ if(this.getText().equals("")) this.setText("Enter your friend's name."); super.onUnfocus(); invalidate(); } public void paint(Graphics g) { XYRect xy = g.getClippingRect(); g.setBackgroundColor(0xffffff); g.fillRect(xy.x,xy.y,this.getWidth(),this.getHeight()); g.clear(); g.setColor(0xb2a1b1); g.drawRect(xy.x,xy.y,this.getWidth(),this.getHeight()); g.setColor(0x777777); this.setFont(f12b); super.paint(g); } protected void layout(int maxWidth, int maxHeight) { super.layout(220, this.getHeight()); setExtent(220, this.getHeight()); } }; vHldmgr.add(nameLabel); vHldmgr.add(friendsName); manager.addCustomField(vHldmgr); _popupMenu.setFont(f); manager.addCustomField(new LabelField(""));



I don't know why the typing is not working.

Please help me.




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

Re: text input in popupScreen

It appears that you may be drawing black/dark text on a black/dark background.  So the text may be captured but you can't see it since it's being drawn in the same colour as your background.


You can verify this by calling getText on your AutoTextEditField to check its contents or by commenting out the lines where you modify the foreground and background colours.

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
Posts: 141
Registered: ‎08-06-2008
My Device: Not Specified

Re: text input in popupScreen

Hi Mark,

Happy New Year!


I tried to catch the input but it's not catching.

But the other problem is that ObjectChoiceField is not working too.




Posts: 4,764
Registered: ‎07-21-2008
My Device: Not Specified

Re: text input in popupScreen

[ Edited ]

Is this all of your code posted here?


I have a suspicion that you have an override of keyChar() somewhere that is "eating"  all of the key events.


Maker certain that you are correctly re-delegating any unhandled keystrokes, like this:

protected boolean keyChar(char c, int status, int time) { switch(c){ case Characters.ESCAPE: onClose(); return true; } return super.keyChar(c,status,time); }


Message Edited by RexDoug on 01-05-2009 09:41 AM
Posts: 141
Registered: ‎08-06-2008
My Device: Not Specified

Re: text input in popupScreen



I had same thought but no use.


I'm extending PopupScreen like below.


public class FriendListPopup extends PopupScreen


and calling

FriendListPopup flPopUp = new FriendListPopup();



I don't know what is wrong.




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

Re: text input in popupScreen

personally i prefer to use pushModalScreen for input screens.
my popupeditscreen looks a lot less complicated compared to yours.
i basically take a popupscreen, add an editfield, handle special keys (enter, escape etc) and navigationclick and return the value by using a callback.

i would suggest you start with something that simple, too. if it works you can still change the layout, the design etc.
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
Regular Contributor
Posts: 77
Registered: ‎11-03-2009
My Device: 9810 Torch
My Carrier: VIPnet

Re: text input in popupScreen

I am facing similar problem with AutoTextEditField, which I am extending, since I want to change the background when I enter or leave the field.


The problem is with the line graphics.clear(), which, as it seems to me, sets all to some default value, and the cursor turns white (instead of the default blue).  I suppose you are having similar problem with the same line (graphics.clear()).