BlackBerry Forums Support Community
              

Closed Thread
 
Thread Tools
Old 12-10-2007, 04:37 AM   #1
jonneymendoza
Knows Where the Search Button Is
 
Join Date: Dec 2007
Model: 8800
PIN: N/A
Carrier: vodafone
Posts: 21
Default key listener in form

Please Login to Remove!

Hi is it possible to use keylistener in a form? for example when the user press the enter key, i will execute something. similar to how a command button would work on a form screen. thanks in advance
Offline  
Old 12-10-2007, 05:02 AM   #2
simon.hain
CrackBerry Addict
 
Join Date: Apr 2005
Location: hamburg, germany
Model: 8900
Carrier: o2
Posts: 838
Default

sure. overwrite keyChar, handle the things you want and relay the rest to super.keyChar

hth,
simon
__________________
java developer, Devinto, hamburg/germany
Offline  
Old 12-10-2007, 06:00 AM   #3
jonneymendoza
Knows Where the Search Button Is
 
Join Date: Dec 2007
Model: 8800
PIN: N/A
Carrier: vodafone
Posts: 21
Default

thanks. do you have an example of how to do key listeners on a normal canvas class?

i read that i need to implement public boolean keyChar(char key, int status, int time)?

does this keyChar act like a protected void keyPressed(int k) or do i implement the keyChar inside the keyPressed method? im new to blackberry developing and hoping if you can gvie me a starting point to help me implement key char's for blackberry devices and how i can execute it during a form screen. thanks
Offline  
Old 12-10-2007, 11:31 AM   #4
bemshaswing
Talking BlackBerry Encyclopedia
 
Join Date: Oct 2006
Model: 7103
Carrier: Verizon
Posts: 259
Default

you override a canvas's keychar method by extending that class into a custom class and implementing the keychar method. therein, you capture the key and choose to do something with it, or simply move it on to the super.keyChar if you want it handled as it otherwise would be
Offline  
Old 12-11-2007, 04:12 AM   #5
jonneymendoza
Knows Where the Search Button Is
 
Join Date: Dec 2007
Model: 8800
PIN: N/A
Carrier: vodafone
Posts: 21
Default

thanks. here is what i done, i added import net.rim.device.api.ui.Screen;

and then
public class MainCanvas extends Canvas implements CommandListener, Runnable, net.rim.device.api.system.Characters


i then added this:

Code:
    public boolean keyChar(char key, int status, int time)
    {
        if(key ==  net.rim.device.api.system.Characters.ENTER)
        {
            login();
        }
       return true;
   }

I then later added the net.rim.device package located from the blackberry simulator program i downloaded through netbeans version 5. when i try to compile it, it doesnt work.

i get a host of warning messages from the output window with these types of information:

Quote:
Warning: net.rim.device.apps.internal.phone.data.CallerIDIn fo: can't find superclass or interface net.rim.device.apps.internal.phone.api.AddressBook DependentObject
Warning: net.rim.device.apps.internal.phone.data.CallerIDIn fo: can't find superclass or interface net.rim.device.apps.api.framework.model.Persistabl eRIMModel
Warning: net.rim.device.apps.internal.phone.data.CallerIDIn fo: can't find superclass or interface net.rim.device.apps.api.framework.model.FieldProvi der
Warning: net.rim.device.apps.internal.phone.data.CallerIDIn fo: can't find superclass or interface net.rim.device.apps.internal.phone.api.CallerIDPro vider
Warning: net.rim.device.apps.internal.phone.data.CallerIDIn fo: can't find superclass or interface net.rim.device.apps.api.framework.model.DefaultPro vider
Warning: net.rim.device.apps.internal.phone.data.CallerIDIn fo: can't find superclass or interface net.rim.device.apps.api.framework.model.Conversion Provider
Warning: net.rim.device.apps.internal.phone.data.CallerIDIn fo: can't find superclass or interface net.rim.device.apps.api.framework.model.Encryptabl eProvider
Warning: net.rim.device.apps.internal.phone.data.CallerIDIn fo: can't find superclass or interface net.rim.device.apps.api.framework.model.SyncFieldI DProvider

does anybody have any idea what im doing wrong :( thanks in advance
Offline  
Old 12-11-2007, 10:45 AM   #6
bemshaswing
Talking BlackBerry Encyclopedia
 
Join Date: Oct 2006
Model: 7103
Carrier: Verizon
Posts: 259
Default

it looks like an error somewhere else. what version of the simulator are you running (OS version, 4.X) and where are you extending net.rim.device.apps.internal.phone.data.CallerIDIn fo
Offline  
Old 12-12-2007, 04:08 AM   #7
jonneymendoza
Knows Where the Search Button Is
 
Join Date: Dec 2007
Model: 8800
PIN: N/A
Carrier: vodafone
Posts: 21
Default

Quote:
Originally Posted by bemshaswing View Post
it looks like an error somewhere else. what version of the simulator are you running (OS version, 4.X) and where are you extending net.rim.device.apps.internal.phone.data.CallerIDIn fo
im using windows xp sp2, the latest simulator 4.3.0 and i am pointing to x:\Program Files\Research In Motion\BlackBerry JDE 4.3.0\lib which conatins the net_rim_api jar file and added that has a library package from within java netbeans 5.5 project properties
Offline  
Old 12-12-2007, 12:18 PM   #8
bemshaswing
Talking BlackBerry Encyclopedia
 
Join Date: Oct 2006
Model: 7103
Carrier: Verizon
Posts: 259
Default

hm, I haven't toyed with 4.3 enough. I'd say try it on a 4.2.1 which is perhaps more stable.
Offline  
Old 12-14-2007, 05:04 AM   #9
jonneymendoza
Knows Where the Search Button Is
 
Join Date: Dec 2007
Model: 8800
PIN: N/A
Carrier: vodafone
Posts: 21
Default

right i have had a look at the item state listeners, ItemCommandListener and ImageItem , and from what i have gathered so far, i can set a item command listener but what i want is to not use the command button keys, i would like to somehow use the keypressed method from within a form screen, not a command button as i am trying to add a simple button image in a form that when the user selects and presses the enter key on there blackberry or similar device, it will execute the keypressed method.


i have managed to achieve something similar by launching a the form from a thread class and that thread continues to check and see if the user has pressed the enter key from a textfield. basicly from a text field i can press the enter key and bam it works.

unfortunatly thats not what the client wants and therefore wants some kind of button in a form
Offline  
Closed Thread



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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


EMC2 HPE-S HPES Server picture

EMC2 HPE-S HPES Server

$465.00



DIGI EtherLite 160 16-Port Terminal Server,PN: (1P)50000986-01 P picture

DIGI EtherLite 160 16-Port Terminal Server,PN: (1P)50000986-01 P

$260.00



Avtron SLS-10 Server Load Simulator Generator - 2 Channels - 10 kW - Tested ✔️⚡ picture

Avtron SLS-10 Server Load Simulator Generator - 2 Channels - 10 kW - Tested ✔️⚡

$799.00



Server - 92020 - Double Dip Server picture

Server - 92020 - Double Dip Server

$348.84



Intel Server Board S3210SH picture

Intel Server Board S3210SH

$149.98



Canon imagePRESS Server B5100 picture

Canon imagePRESS Server B5100

$1199.00







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