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



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


OEM Dell XPS 8910 8920 8930 Alienware Aurora R5 R6 R7 Front Cooling Fan 7M0F5 picture

OEM Dell XPS 8910 8920 8930 Alienware Aurora R5 R6 R7 Front Cooling Fan 7M0F5

$12.11



NEW DELL OEM REPLACEMENT PROJECTOR LAMP FOR 4220 4320 GENUINE ORIGINAL  picture

NEW DELL OEM REPLACEMENT PROJECTOR LAMP FOR 4220 4320 GENUINE ORIGINAL

$198.22



DELL 330-6581 3306581 725-10229 OEM LAMP FOR 1510X 1610HD 1610X  - Made By DELL picture

DELL 330-6581 3306581 725-10229 OEM LAMP FOR 1510X 1610HD 1610X - Made By DELL

$39.98



Genuine OEM Dell 2375 B2375dnf B2375dfw 110V Fuser fixing N41P2 sku 724-BBCI picture

Genuine OEM Dell 2375 B2375dnf B2375dfw 110V Fuser fixing N41P2 sku 724-BBCI

$94.99



Genuine Dell OEM G Series G7 7790 CPU and Graphics Heatsink Assembly XRF05 picture

Genuine Dell OEM G Series G7 7790 CPU and Graphics Heatsink Assembly XRF05

$20.30



1PCS NEW FIT FOR OEM Dell AC Adapter Dell Alienware DA330PM190 LA330PM190 330W picture

1PCS NEW FIT FOR OEM Dell AC Adapter Dell Alienware DA330PM190 LA330PM190 330W

$117.97







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