BlackBerry Forums Support Community
              

Closed Thread
 
Thread Tools
Old 07-26-2005, 04:22 PM   #1
JetSetter
New Member
 
Join Date: Jul 2005
Model: 7290
Posts: 3
Question Data from Screen into Application

Please Login to Remove!

OK. I'm new at this Blackberry stuff, but experienced as a Software Developer. I need to get data from the screen into my application -- a series of questions and responses. The details about how you get data from the screen into the application seem to have been left out of the 4.0.2 documentation. They mention KeyboardListener (undocumented); I found KeyListener but can't figure out how to make it do what I want. I want to have the data presented to the application when the user hits the NewLine key, without requiring any trackwheel involvement. Could someone out there tell me how you do this?

Thanks in advance.
Offline  
Old 07-27-2005, 12:36 PM   #2
sacramentojoe
Knows Where the Search Button Is
 
Join Date: Apr 2005
Model: 7230
Posts: 30
Default

You need to create a java file that extends KeyListener then you have to override the
keyChar method.

public class MyGui implements KeyListener{

public boolean keyChar(char key, int status, int time){
switch(key){
case Characters.ENTER:
//do whatever when they hit enter
return true;
}
return super.keyChar(key,status,time);

}

}


Something like this should get you started.
Offline  
Old 07-27-2005, 05:43 PM   #3
JetSetter
New Member
 
Join Date: Jul 2005
Model: 7290
Posts: 3
Default

Thanks, Joe. I'll try it out soon.
Two additional questions: Where / How did you find this out? It's not in any manuals I've been able to find.
Second, and more importantly, where does the data show up? Is a string built, character by character, for the field on the screen? How is the data accessed? A good example in the manual (rather than examples of drawing different shaped buttons) would have saved much frustration.
Offline  
Old 07-28-2005, 11:36 AM   #4
sacramentojoe
Knows Where the Search Button Is
 
Join Date: Apr 2005
Model: 7230
Posts: 30
Default

Quote:
Originally Posted by JetSetter
Thanks, Joe. I'll try it out soon.
Two additional questions: Where / How did you find this out? It's not in any manuals I've been able to find.
Second, and more importantly, where does the data show up? Is a string built, character by character, for the field on the screen? How is the data accessed? A good example in the manual (rather than examples of drawing different shaped buttons) would have saved much frustration.

I found it out from the JavaDocs. Everything you'll need to know is there.

What do you mean where does the Data show up?

Lets say you have an AutoTextEditField
AutoTextEditField userName = new AutoTextEditField("UserName: ","");
then, you have to create a String:
String userNameValue = userName.getText();
Offline  
Old 07-29-2005, 10:31 PM   #5
JetSetter
New Member
 
Join Date: Jul 2005
Model: 7290
Posts: 3
Default

Thanks for the pointers, Joe. I figured out how to make it work. I'm sure there must be a simpler and more clever way that what I came up with, but what I have works, and it's only a temporary measure (I hope).
Offline  
Old 08-01-2005, 04:14 PM   #6
timinator
Knows Where the Search Button Is
 
timinator's Avatar
 
Join Date: Jul 2005
Location: Washington
Model: 8300
Carrier: AT&T
Posts: 29
Default

I figured I would post here since this is related. I'm trying to do something similar. I put this together by looking at some of the examples in the Developers Guide. But I'm getting a java:16 error, "MyTextInput is not abstract and does not override abstract method keyStatus(int,int) in net.rim.device.api.system.KeyListener"
Here's my sample code:

Code:
import net.rim.device.api.ui.*;
import net.rim.device.api.ui.component.*;
import net.rim.device.api.ui.container.*;
import net.rim.device.api.system.*;
import net.rim.device.api.util.*;
import java.util.*;

// MyTextInput.java Class --------------------------------------------------------------------------
public class MyTextInput extends net.rim.device.api.ui.UiApplication implements KeyListener
{
    private AutoTextEditField inputField;
    private LabelField appTitle;
    
    public static void main(String[] args)
    {
        MyTextInput TIinstance = new MyTextInput(); 
        TIinstance.enterEventDispatcher();      
    }
    
    public MyTextInput()
    {
        MainScreen inputScreen = new MainScreen();
        appTitle = new LabelField("Input Test");
        inputField = new AutoTextEditField("Input:","");
        inputScreen.setTitle(appTitle);
        inputScreen.add(inputField);
        inputScreen.addKeyListener(this);
        pushScreen(inputScreen);
    }

    public void onExit()
    {
        Dialog.alert("Exiting.");
    }
}
What am I missing here?
__________________
===================================
"There are 10 types of people in the world.
Those that understand binary and those that don't!"
www.timothytrimble.info - The ART of S/W Development
==================================
Offline  
Old 08-01-2005, 06:38 PM   #7
timinator
Knows Where the Search Button Is
 
timinator's Avatar
 
Join Date: Jul 2005
Location: Washington
Model: 8300
Carrier: AT&T
Posts: 29
Default

I just figured it out. Seems that the KeyListener is not needed for the AutoTextEditField.
Here's the working code (for those who are also just getting started):
Code:
import net.rim.device.api.ui.*;
import net.rim.device.api.ui.component.*;
import net.rim.device.api.ui.container.*;
import net.rim.device.api.system.*;
import net.rim.device.api.util.*;
import java.util.*;

// MyTextInput.java Class --------------------------------------------------------------------------
public class MyTextInput extends net.rim.device.api.ui.UiApplication
{
    private AutoTextEditField inputField;
    private LabelField appTitle;
    
    public static void main(String[] args)
    {
        MyTextInput TIinstance = new MyTextInput(); 
        TIinstance.enterEventDispatcher();      
    }
    
    public MyTextInput()
    {
        MainScreen inputScreen = new MainScreen();
        appTitle = new LabelField("Input Test");
        inputField = new AutoTextEditField("Input:","");
        inputScreen.setTitle(appTitle);
        inputScreen.add(inputField);
        pushScreen(inputScreen);
    }

    public void onExit()
    {
        Dialog.alert("Exiting.");
    }
}
Now my next step is to add another edit field, and store the results.
__________________
===================================
"There are 10 types of people in the world.
Those that understand binary and those that don't!"
www.timothytrimble.info - The ART of S/W Development
==================================
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

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

Forum Jump


Crystal Dental Digital RVG Intra Oral Water Resistant Sensor Size 1 picture

Crystal Dental Digital RVG Intra Oral Water Resistant Sensor Size 1

$2564.99



LOT OF 5 CRYSTAL MINIATURE CIRCUIT BREAKER SP-C-40 40 AMPS SINGLE POLE picture

LOT OF 5 CRYSTAL MINIATURE CIRCUIT BREAKER SP-C-40 40 AMPS SINGLE POLE

$149.25



GORILLA Crystal Clear  Water Resistant GLUE ~ Bond Wood Stone Metal Glass 5.75oz picture

GORILLA Crystal Clear Water Resistant GLUE ~ Bond Wood Stone Metal Glass 5.75oz

$21.95



Quartz Single Crystal Wafers AT cut. Double sided polished. picture

Quartz Single Crystal Wafers AT cut. Double sided polished.

$8.95



Dental Glass Quartz Fiber Post Root Canal Pin Straight Screw Restorative 1.0-1.8 picture

Dental Glass Quartz Fiber Post Root Canal Pin Straight Screw Restorative 1.0-1.8

$256.61



Dental Fiber Post Resin Screw Thread Quartz Drills Yellow/Red USPS CEFDA picture

Dental Fiber Post Resin Screw Thread Quartz Drills Yellow/Red USPS CEFDA

$244.36







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