BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 03-22-2007, 02:00 PM   #1 (permalink)
Thumbs Must Hurt
 
Join Date: Feb 2007
Model: 8100
Carrier: T-Mobile
Posts: 54
Post Thanks: 0
Thanked 0 Times in 0 Posts
Angry DEL key not reponding in numeric field? Sample code included.

Please Login to Remove!

Hi all,

Probably a stooopid noob question.
I have a simple BasicEditField of style FILTER_REAL_NUMERIC.

Very simple, not even a label.

When I type in the field, all is well. When I try to press the DEL key to backspace and correct. Or, if I move the trackball to the point in the text I want to correct, it does not respond as I'd assumed it would. I seem to only have the option to use the menu to alter the text using the cut/paste/clear options from the menu.

What gives?

Here's my simple class code...



Code:
package com.wcs.blackberry;

import net.rim.device.api.system.Characters;
import net.rim.device.api.ui.UiApplication;
import net.rim.device.api.ui.component.BasicEditField;
import net.rim.device.api.ui.component.LabelField;
import net.rim.device.api.ui.container.MainScreen;

// The Sandbox application is a Blackberry Pearl testbed.
public class Sandbox extends UiApplication
{
  public static void main(String[] args)
  {
    Sandbox theApp = new Sandbox();
    theApp.enterEventDispatcher();
  }

  public Sandbox()
  {
    pushScreen(new SandboxScreen());
  }
}

final class SandboxScreen extends MainScreen
{
  // Add the title and a simple numeric field
  public SandboxScreen()
  {
    super(DEFAULT_MENU | DEFAULT_CLOSE);

    setTitle(new LabelField("BlackBerry Pearl Sandbox", LabelField.ELLIPSIS
        | LabelField.USE_ALL_WIDTH));

    BasicEditField basicField = new BasicEditField(
        BasicEditField.FILTER_REAL_NUMERIC);
    add(basicField);
  }

  public boolean onClose()
  {
    System.exit(0);
    return true;
  }

  public boolean keyChar(char key, int status, int time)
  {
    boolean retval = false;
    switch (key)
    {
      case Characters.ESCAPE:
        onClose();
        retval = true;
        break;
    }
    return retval;
  }

}

Last edited by mdwheaton : 03-22-2007 at 11:09 PM. Reason: Added code.
Offline  
Old 03-22-2007, 11:10 PM   #2 (permalink)
Thumbs Must Hurt
 
Join Date: Feb 2007
Model: 8100
Carrier: T-Mobile
Posts: 54
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default Added my code

Bumped since I added my code.
Offline  
Old 03-23-2007, 01:18 AM   #3 (permalink)
Knows Where the Search Button Is
 
Join Date: Sep 2005
Location: Mumbai, India
Model: 8100
Carrier: Airtel
Posts: 31
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi mdwheaton,

In keyChar() method u need to call super.keyChar().
I made little change in ur keyChar() method for u...
Code:
  public boolean keyChar(char key, int status, int time)
  {
    switch (key)
    {
      case Characters.ESCAPE:
        onClose();
        return true;
    }
    return super.keyChar(key, status, time);
  }
Hope this will help u..

Cheers..
Chetan Sawant
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.