2

How to programmatically open/close or force the virtual keyboard to open in reduced form in Blackberry?

I tried searching it but couldn't find a way to do it.

I also tried finding some links in Blackberry Support Forums like

http://supportforums.blackberry.com/t5/Java-Development/Blackberry-torch-force-reduced-virtual-keyboard-layout/td-p/618989

But this was not helpful.

EDIT:

Here is the code I am using to define my editField:

/** Horizontal field manager to hold text field*/
  HorizontalFieldManager hfmBadgeNo = new HorizontalFieldManager(FIELD_HCENTER)
  {
   protected void paintBackground(Graphics graphics) {
    graphics.setColor(Color.DARKGRAY);
    graphics.drawRoundRect(60, 10, Display.getWidth() - (60 * 2), getField(0).getHeight() + 10, 5, 5);

    super.paintBackground(graphics);
   }
  };

  // text field to enter Badge Number, it allows only Numeric Digits
  EditField txtEventNumber = new EditField() {
   public void paint(Graphics graphics) {
    super.paint(graphics);
    int oldColor = Color.GRAY;
    graphics.setBackgroundColor(Color.WHITE);
    graphics.setColor(0x181818);
    Font font = this.getFont().derive(Font.EMBOSSED_EFFECT, 54);
    this.setFont(font);
    graphics.setColor(oldColor);
    super.paint(graphics);
   }
   protected void onFocus(int direction) {
    if (VirtualKeyboard.isSupported())
     // Show keyboard
     getScreen().getVirtualKeyboard().setVisibility(VirtualKeyboard.SHOW);
    this.setCursorPosition(this.getTextLength());
    invalidate();
    super.onFocus(direction);
   };
   protected void onUnfocus() {
    if (VirtualKeyboard.isSupported())
     // Hide keyboard
     getScreen().getVirtualKeyboard().setVisibility(VirtualKeyboard.HIDE_FORCE);
    this.setCursorPosition(this.getTextLength());
    invalidate();
    super.onUnfocus();
   };
  };
  // Allows numeric value
  txtEventNumber.setFilter(TextFilter.get(TextFilter.NUMERIC));
  txtEventNumber.setMargin(10 + 5, 60 + 5, 5, 60 + 5);

  // Add text field to manager
  hfmBadgeNo.add(txtEventNumber);

Reduced Keyboard is as follows:

enter image description here

Full keyboard is as follows:

enter image description here

halfer
  • 19,824
  • 17
  • 99
  • 186
Parth Bhatt
  • 19,381
  • 28
  • 133
  • 216
  • Please post the code you're using to define your edit field, or whatever the keyboard is being used for. Also, which device and OS version are you testing on? – Nate Jan 10 '13 at 07:44
  • And please also clarify whether you have tried something, and you are getting the keyboard shown in the lower picture, or if you're just showing us the two pictures so that we know what you mean by *reduced keyboard*. Thanks. – Nate Jan 10 '13 at 08:26
  • @Nate: I have posted the code where in I define my edit field. Also I have just added reduced keyboard and full keyboard screenshots just for you all to know what exactly I mean when I say reduced keyboard.. – Parth Bhatt Jan 11 '13 at 12:09
  • Your code above worked for me. The numeric virtual keyboard (like your first screenshot) shows when the field is focused, and hides when focus is removed. What is not working for you? Please describe the behaviour that the code shown above is producing. And, *again*, what device and OS version are you testing this on? – Nate Jan 12 '13 at 02:21
  • @Nate This may be the case with your device as you might have selected **"Enable Reduced Keyboard"** from Menu list in your device. I want reduced keyboard to be opened even if you have not selected **"Enable Reduced Keyboard"** from the Menu list in your device and I am using BB Torch 9800 (OS 6.0) and BB Torch 9860 (OS 7.1). Can you help me do this? – Parth Bhatt Jan 12 '13 at 05:57
  • Ok, I see what you're trying to do. You want the *SureType* keyboard, even if the user has setup their Options to select the *Full Keyboard*. I don't know if you can do that. That is kind of a violation of the meaning of user-selectable defaults. If the user has chosen the Full Keyboard, I'm not sure it's a good idea to give them something else. But, maybe someone else knows how to do this ... – Nate Jan 12 '13 at 11:02

1 Answers1

2

BlackBerry Java based devices (BlackBerry OS up to and including 7.1) The keyboard is determined by the TextFilter in effect for the input field with focus. There are a number of predefined filters that can be specified in the field constructor style argument. Or you can create your own filter, either from scratch or by combining the existing ones, if none of those meet your needs.

Richard
  • 8,920
  • 2
  • 18
  • 24
  • looks like he probably wants to use something like [FILTER_INTEGER](http://www.blackberry.com/developers/docs/7.1.0api/net/rim/device/api/ui/component/BasicEditField.html#FILTER_INTEGER), based on the screenshots. – Nate Jan 11 '13 at 09:18
  • @Richard: Please check I have edited my question and added the code. If you can help me with this. – Parth Bhatt Jan 11 '13 at 12:12