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
Regular Contributor
bagir
Posts: 52
Registered: ‎06-24-2010
My Device: T-Mobile
Accepted Solution

key char shortcut doesn't work

Hi all,

 

I have added a keyboard shortcut for my button to my application, I try to test it on Simulator with JDE 4.5, Curve 8300, I want that when the user press "Enter" on the Button the application move to "contents" page, The "Enter" key is working. But When the user press "C" the application move to "contents" page, but it doesn't work, this is my code :

 

CustomButtonField colour2 = new CustomButtonField("C\u0332ontent",  Field.FOCUSABLE | Field.FIELD_HCENTER)
{
protected boolean navigationClick(int status, int time)
{ System.out.println("In Button"); getApp().ContentsMunif(-2); invalidate(); return false; } public boolean keyChar(char key, int status, int time)
{ if (key == Characters.ENTER || key == Characters.LATIN_CAPITAL_LETTER_C)
{ System.out.println("In Button"); getApp().ContentsMunif(-2); invalidate(); } invalidate(); return false; }
public void paint(Graphics graphics)
{ graphics.setColor(0xffffff); graphics.clear(); super.paint(graphics); } }

Please Help me, why the "C" key doesn't work? What is the mistake in my code that makes it doesn't work?

 

 

 

Developer
simon_hain
Posts: 16,282
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport

Re: key char shortcut doesn't work

you are aware of only checking for the capital c? aka 'C'? the c + shift one?

----------------------------------------------------------
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
Regular Contributor
bagir
Posts: 52
Registered: ‎06-24-2010
My Device: T-Mobile

Re: key char shortcut doesn't work

Thank you for answering my Problem,  Peter.

Yes, I am Using Capital "C", I have tried not only on Simulator curve 8300, but in My BlackBerry Curve  8520 after Signing key process and installation process finish.

I try Shift-C, Alt-C, Alt-Shift-C, but it still doesn't work.

 

What is the problem, Is my code still incomplete? What Should I do?

 

Developer
simon_hain
Posts: 16,282
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport

Re: key char shortcut doesn't work

check the char value, i suspect it is a lower case 'c' and the shift key is added as a status

----------------------------------------------------------
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
Regular Contributor
bagir
Posts: 52
Registered: ‎06-24-2010
My Device: T-Mobile

Re: key char shortcut doesn't work

Thank you peter,

I also have tried the lower 'c', but it doesn't work.

please explain to me what this value check mean and how? and what changes to the code should i do?

 

 

Developer
simon_hain
Posts: 16,282
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport

Re: key char shortcut doesn't work

i am kind of getting multiple personality disorder :smileywink:

 

try

key=='c'

----------------------------------------------------------
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
Regular Contributor
bagir
Posts: 52
Registered: ‎06-24-2010
My Device: T-Mobile

Re: key char shortcut doesn't work

thank you, it's work....

:smileyvery-happy:

Regular Contributor
bagir
Posts: 52
Registered: ‎06-24-2010
My Device: T-Mobile

Re: key char shortcut doesn't work

hey, wait peter.

It works only when the cursor is over the button, but when it is not over the button, it doesn't work.

How to make it work not only when the cursor over the button?

Developer
simon_hain
Posts: 16,282
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport

Re: key char shortcut doesn't work

overwrite it on the screen level. and stop calling me peter :smileytongue:

----------------------------------------------------------
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
Regular Contributor
bagir
Posts: 52
Registered: ‎06-24-2010
My Device: T-Mobile

Re: key char shortcut doesn't work

Oh My God, I am so Sorry Simon, ...:smileysurprised:

 

Thank you Simon, I have override in on Screen level, but There is a problem,

I have five Button use the keypress, when I pressed enter it will go to the first if clause only.

But When I remove the key == Characters.ENTER, the enter key is unknown.

Please Help me how to solve this Problem?