BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 10-15-2007, 06:17 AM   #1 (permalink)
Knows Where the Search Button Is
 
Join Date: Mar 2007
Model: 8707v
Carrier: c
Posts: 20
Post Thanks: 0
Thanked 0 Times in 0 Posts
Question ContextMenu with call and sms option

Please Login to Remove!

Hi,
when I write a text in BB contains a phone number if I push the menu button it appears the ContextMenu with the call and sms options for the number.

AnyOne know how can I make this with BB Jde ?

Thanks in advance
Offline  
Old 10-15-2007, 07:16 AM   #2 (permalink)
CrackBerry Addict
 
Join Date: Apr 2005
Location: hamburg, germany
Model: 8900
Carrier: o2
Posts: 838
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

you need to write a function that checks if the text under the cursor is a telephone number. in the code below this is checkNumber(focus) which returns a boolean.
try to implement this function using
EditField.getCursorPosition and EditField.getText (or RichtextField) to get the selected word (stringtokenizer on space maybe?).
After you got the word the cursor is positioned on you can check if it is a valid phone number.

Code:
  public boolean trackwheelClick(int status,int time) {
        Field focus = getLeafFieldWithFocus();
        Menu menu = new Menu();

        MenuItem send = new MenuItem("send SMS", 0, 0) {
            public void run() {
                sendSMS();
            }
        };
 MenuItem makeCall = new MenuItem("make Call", 0, 0) {
            public void run() {
                makeCall();
            }
        };

        if (checkNumber(focus)) {
        menu.add(send);
        menu.add(makeCall);
}
        menu.add(focus.getContextMenu());
return true;
}
would be a handy thing to have, you'd be welcome to share if you implement it.
__________________
java developer, Devinto, hamburg/germany
Offline  
Old 10-15-2007, 09:15 AM   #3 (permalink)
Knows Where the Search Button Is
 
Join Date: Mar 2007
Model: 8707v
Carrier: c
Posts: 20
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks simon.hain,
i go to try it.
I think the BB put this menu automatically when detect a number.
Offline  
Old 10-15-2007, 09:34 AM   #4 (permalink)
CrackBerry Addict
 
Join Date: Apr 2005
Location: hamburg, germany
Model: 8900
Carrier: o2
Posts: 838
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by pockettest View Post
I think the BB put this menu automatically when detect a number.
sure, but it has some internal functionality that detects the number, that's the point. there is no such function in the API afaik. would be similar to the filter-type FILTER_PHONE.

to get the word the cursor is on you can use String.indexOf and String.lastIndexOf working with the space-char, the text of the field and the cursor position.

Now you can check this string if it consists only of allowed chars like numbers, slashes or plusses.
__________________
java developer, Devinto, hamburg/germany
Offline  
Closed Thread


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





Copyright 2004-2014 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.