BlackBerry Forums Support Community
              

Closed Thread
 
LinkBack Thread Tools
Old 07-26-2005, 04:22 PM   #1 (permalink)
New Member
 
Join Date: Jul 2005
Model: 7290
Posts: 3
Post Thanks: 0
Thanked 0 Times in 0 Posts
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 (permalink)
Knows Where the Search Button Is
 
Join Date: Apr 2005
Model: 7230
Posts: 30
Post Thanks: 0
Thanked 0 Times in 0 Posts
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 (permalink)
New Member
 
Join Date: Jul 2005
Model: 7290
Posts: 3
Post Thanks: 0
Thanked 0 Times in 0 Posts
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 (permalink)
Knows Where the Search Button Is
 
Join Date: Apr 2005
Model: 7230
Posts: 30
Post Thanks: 0
Thanked 0 Times in 0 Posts
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 (permalink)
New Member
 
Join Date: Jul 2005
Model: 7290
Posts: 3
Post Thanks: 0
Thanked 0 Times in 0 Posts
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 (permalink)
Knows Where the Search Button Is
 
timinator's Avatar
 
Join Date: Jul 2005
Location: Washington
Model: 8300
Carrier: AT&T
Posts: 29
Post Thanks: 0
Thanked 0 Times in 0 Posts
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 (permalink)
Knows Where the Search Button Is
 
timinator's Avatar
 
Join Date: Jul 2005
Location: Washington
Model: 8300
Carrier: AT&T
Posts: 29
Post Thanks: 0
Thanked 0 Times in 0 Posts
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

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

NEW IBM SELECTRIC I TYPEWRITER PART, RED MARGIN POINTER OEM NOS
$9.99
NEW IBM SELECTRIC I TYPEWRITER PART, RED MARGIN POINTER OEM NOS  pictureOEM IBM SurePOS 700 4800-743/783 250W Power Supply DPS-250AB-45A 46N1999 46N1998
$27.0
OEM IBM SurePOS 700 4800-743/783 250W Power Supply DPS-250AB-45A 46N1999 46N1998 picture(4) IBM 1337761 Genuine OEM Easystrike Correctable Ribbon Cassette - NOS
$40.0
(4) IBM 1337761 Genuine OEM Easystrike Correctable Ribbon Cassette - NOS pictureOEM IBM Wheelwriter 5 Part: Paper Release Lever & Bellcrank
$5.99
OEM  IBM  Wheelwriter 5 Part:  Paper Release Lever & Bellcrank pictureOEM BULB with Housing for IBM SP-LAMP-006 Projector with 180 Day Warranty
$130.16
OEM BULB with Housing for IBM SP-LAMP-006 Projector with 180 Day Warranty picture






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