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
Developer
Posts: 300
Registered: ‎03-12-2009
My Device: Not Specified
Accepted Solution

keyDown overrides all other keys

I want to capture certain keypresses so I can use the number pad as a "controller" of sort.. but i want all the other buttons to act as normal.

 

How would I go about doing this?

 

 

//this manager is used for the static background image mainManager = new VerticalFieldManager( NO_HORIZONTAL_SCROLL | NO_VERTICAL_SCROLL ) { protected boolean keyDown(int keycode, int time) { try { if (keycode == 5701632 || keycode == 5701666 || keycode == 5701633) { } else if (keycode == 4521984 || keycode == 4521985 || keycode == 4522018) { } else if (keycode == 5373952 || keycode == 5373953 || keycode == 5373986) { } else if (keycode == 5439488 || keycode == 5439489 || keycode == 5439522) { } else if (keycode == 4456448 || keycode == 445644 || keycode == 4456484) { } else if (keycode == 4587520 || keycode == 4587521 || keycode == 4587554) { } else if (keycode == 5898240 || keycode == 5898241 || keycode == 5898274) { } else if (keycode == 5767168 || keycode == 5767169 || keycode == 5767202) { } // blackberry button else if (keycode == 268566528) { } // red button else if (keycode == 1179648) { } // back button else if (keycode == 1769472) { } } catch (MediaException e) { // TODO Auto-generated catch block e.printStackTrace(); } return true; } protected boolean keyUp(int keycode, int time) { return true; } };

 

Or do I actually have to code for all of the other buttons?

 

Developer
Posts: 300
Registered: ‎03-12-2009
My Device: Not Specified

Re: keyDown overrides all other keys

I just tested on a few other similuators and it looks like these keycodes aren't the same foreverything..

 

obviously I'm missing something here.. how will I beable to check if someone is hitting the "TWO" key if 2 is also E and e on a Query but it could be a E and R on a pearl? does that make sense?

 

Basically i want to use the number pad for certain functions on the screen, but without the user having to press "alt"for full keyboard devices..

Developer
Posts: 300
Registered: ‎03-12-2009
My Device: Not Specified

Re: keyDown overrides all other keys

Is there a way to set a "NUM LOCK" when opening an app?
Developer
Posts: 16,992
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: keyDown overrides all other keys

the reduced keyboard prohibits certain checks on the key level because you can not find out which keycodes are mapped to a key.

short of event injection i know of no way to force the num lock mode.
you can, however, set filters in your editfield, like FILTER_NUMERIC which allows only numbers to be typed and switches the keyboard to numeric mode.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
Posts: 27
Registered: ‎04-24-2009
My Device: Not Specified

Re: keyDown overrides all other keys

Hi footose,

 

you need to return false, if the key was not consumed by your method, in order to tell the system that the key needs to be processed further. Means, in your if structure you need to return true if the key was one you expected and you dealt with false otherwise.

 

You might consider to implement your if structure as a switch-case structure. Is better to read later on for maintenance.

 

Regards,

 

Carsten

 

---

If you consider my answer to be the solution to your question, a Kudos will be appreciated.
Developer
Posts: 300
Registered: ‎03-12-2009
My Device: Not Specified

Re: keyDown overrides all other keys

Thank you very much!
Developer
Posts: 300
Registered: ‎03-12-2009
My Device: Not Specified

Re: keyDown overrides all other keys

simon thanks as well..