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
Regular Contributor
Posts: 69
Registered: ‎01-17-2010
My Device: 9700 Bold
My Carrier: Airtel
Accepted Solution

Strange behavior of EditField

Hi All,

 

My requirement is to display some text (using EditField / RichTextField or any other field). if i click over a word on that text and if the word is number then a dialog should get pop-up. 

example : "This is my number - 9860922075" and if click over number then dialog should get pop-up showing number as 9860922075 and a call button below it, hitting which the number should get called.

 

When i am displaying this number as a EditField on the dialog, the field is actually not getting edited  dont know why? even if i called setEditable true manually then also its not getting editable., while the call button is worling as required.

 

please help me if someone has any ideas.

AbhishekPXP
Contributor
Posts: 45
Registered: ‎12-20-2010
My Device: Not Specified

Re: Strange behavior of EditField

Hi Abhishek,

 

Can you please paste your code, it will be helpful to identify the problem with ur EditField.

 

-Roshni

Regular Contributor
Posts: 69
Registered: ‎01-17-2010
My Device: 9700 Bold
My Carrier: Airtel

Re: Strange behavior of EditField

[ Edited ]

Hi Roshni,

 

Following is the code snippet :

 

trans_field = ActiveRichTextField

num_field - EditField (the problamatic EditField whihc is not getting edited actually Smiley Sad )

 

 

                        int currentPosition = trans_field.getCursorPosition();
                        String sample = text2.substring(0,currentPosition);
                        int index = sample.lastIndexOf(' ');
                        String numText = text2.substring(index+1);
                        if(numText.indexOf(' ') > 0)
                            callNum = numText.substring(0,numText.indexOf(' '));                                
                        else 
                            callNum = numText;
                        if(PhoneNumberUtility.isNormalizedPhoneNumber(callNum)) {   
                            numField = new EditField("Call : ",callNum);                            
                            ShareManager callDialog = new ShareManager();
                            callDialog.add(numField);
                            ButtonField callButton = new ButtonField("Call", ButtonField.FIELD_HCENTER) {  
                                protected boolean navigationClick(int status, int time) {   
                                    try {
                                        Invoke.invokeApplication(Invoke.APP_TYPE_PHONE,new PhoneArguments(PhoneArguments.ARG_CALL,numField.getText()));
                                        return true;
                                    } catch (Exception e) {
                                        logger.error("call", e);
                                        Dialog.alert(resources.getString(MSG_OPERATION_ERROR));                                
                                    }
                                    return false;
                                }
                            };
                            callDialog.add(callButton);
                            //synchronized(net.rim.device.api.ui.UiApplication.getEventLock()){     
                                net.rim.device.api.ui.UiApplication.getUiApplication().pushScreen(callDialog);

 

AbhishekPXP
Developer
Posts: 2,268
Registered: ‎07-08-2009
My Device: various
My Carrier: various

Re: Strange behavior of EditField

RichTextField is never editable. Make your numField an EditField and see how it works.

 

In addition: when exactly your callNum is being extracted? I'm aftraid you are trying to get it long before the user has had a chance to edit it. I don't see any numField.getText calls - they are relevant, so if you have them somewhere else, that piece of code is important, too.

 

----------------------------------------------------------
please click 'Accept Solution' on posts that provide the solution to the question you've posted. Don't say "Thanks", press 'Like' button instead!
Contributor
Posts: 45
Registered: ‎12-20-2010
My Device: Not Specified

Re: Strange behavior of EditField

[ Edited ]

Hi Abhishek,

 

Try overriding the keyChar method of num_field. Something like this:

 

num_Field = new EditField("") {

 protected boolean keyChar(char key, int status, int time){

 // check that all the characters of ur num_field are numbers

 // check if the no of characters in ur num_field is 10 (as its no to call)

// if num_field has all no and 10 length than show dialog else call super.keyChar()

}

};

 

-Roshni

 

Press Kudos if solved.

Regular Contributor
Posts: 69
Registered: ‎01-17-2010
My Device: 9700 Bold
My Carrier: Airtel

Re: Strange behavior of EditField

thanks for the reply Roshni, but i have done that. "PhoneNumberUtility.isNormalizedPhoneNumber(callNum)" in my code doing the same thing. What i want that whenever the clicked word is number (whatever valid or invalid) i need to show it using editfield on a popup dialog with a call button, so that user can edit the number (if its invalid one or can add std or international code) and then call it using call button.
AbhishekPXP
Developer
Posts: 2,268
Registered: ‎07-08-2009
My Device: various
My Carrier: various

Re: Strange behavior of EditField

Do you have the code for your PopupScreen already? Can you show how you construct it?

----------------------------------------------------------
please click 'Accept Solution' on posts that provide the solution to the question you've posted. Don't say "Thanks", press 'Like' button instead!
Regular Contributor
Posts: 69
Registered: ‎01-17-2010
My Device: 9700 Bold
My Carrier: Airtel

Re: Strange behavior of EditField

 
AbhishekPXP
Regular Contributor
Posts: 69
Registered: ‎01-17-2010
My Device: 9700 Bold
My Carrier: Airtel

Re: Strange behavior of EditField

Hi,

 

code for PopupDialog,

 

class ShareManager extends PopupScreen {
        public ShareManager(long style) { 
                super(new VerticalFieldManager(Field.FIELD_HCENTER));
        }
        
        public void add(Field field){   
                super.add(field);
        }
        
        public void show() {    
                synchronized(UiApplication.getEventLock()){     
                        UiApplication.getUiApplication().pushScreen(this);
                }               
        }       
        protected boolean keyDown(int keycode, int time) {  
            if(keycode == 1769472){   
                close();
            }
            return true;
        }
        
        public void close() {   
            synchronized(UiApplication.getEventLock()){ 
                UiApplication.getUiApplication().popScreen(this);
            }
        }

 regards

Abhishek

AbhishekPXP
Developer
Posts: 2,268
Registered: ‎07-08-2009
My Device: various
My Carrier: various

Re: Strange behavior of EditField

Can you show what you add there?

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