Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Highlighted
Developer
Posts: 367
Registered: ‎11-25-2009
My Device: Not Specified
Accepted Solution

KeyChar() not recognizing Enter key

Hi Everyone,

 

I've implemented a custom field, HrefField. I have set the fieldchangelistener to respond to the trackball & wheel, as well as the space bar. This is working fine. I am trying to get it to work for the enter key, too, but for some reason it will not recognize the enter key as input. Here is my code:

 

 

href = new HrefField(temp, 0x181818, 0xffffff, 0x00EF3825) {
	protected boolean trackwheelClick(int status, int time) {
		fieldChangeNotify(0);
		return true;
	}

	public boolean keyChar(char key, int status, int time) {
		switch (key) {
			case Characters.ENTER: {
			  fieldChangeNotify(0);
			  return true;
			}
			case Characters.SPACE: {
			  fieldChangeNotify(0);
			  return true;
			}
		}

		return super.keyChar(key, status, time);

	}
};

href.setChangeListener(this);

Thanks!

 

 

Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: KeyChar() not recognizing Enter key

What does HrefField extend?

Developer
Posts: 367
Registered: ‎11-25-2009
My Device: Not Specified

Re: KeyChar() not recognizing Enter key

HrefField extends Field

 

I have also tried extending RichTextField, and it yields the same result....

Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: KeyChar() not recognizing Enter key

I presume that it does not override keyChar, keyUp, keyDown etc?  I also presume that the screen that it is in doesn't swallow them as well.

 

The only time I've seen this issue (when it wasn't caused by something else swallowing the Enter, was a BasicEditField that had the BasciEditField.NO_NEWLINE specified.  Not the case here unfortunately. 

Developer
Posts: 367
Registered: ‎11-25-2009
My Device: Not Specified

Re: KeyChar() not recognizing Enter key

Ah, I had my classes set up where "SearchScreen" starts a threaded http request and instantiates "GetResults", which makes use of HrefField. It turns out that "SearchScreen" was implementing KeyListener, which was causing a swallow.

 

Thanks for your help!