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

Native Development

Reply
Highlighted
Contributor
Posts: 45
Registered: ‎04-11-2012
My Device: Z10 Limited Edition
My Carrier: 00201003883386

how to capture keyboard input in cascades?

hi All,

       I needto capture keyboard input in cascades because I am developing remote control app. I know that keyboard support doesnt exist in cascades now but I know that support is available in native C. I want a tutorial about how to use C code in cascades to capture keyboard input.

 

 

Thank you,

Hisham

When you are young, work to learn. Not to earn !
Contributor
Posts: 45
Registered: ‎04-11-2012
My Device: Z10 Limited Edition
My Carrier: 00201003883386

Re: how to capture keyboard input in cascades?

More than a month without reply Smiley Sad
When you are young, work to learn. Not to earn !
Retired
Posts: 749
Registered: ‎12-16-2008
My Device: BlackBerry Z30
My Carrier: Bell

Re: how to capture keyboard input in cascades?

You can capture keyboard events using BPS, as show here:

http://developer.blackberry.com/native/documentation/bb10/keyboard_using_2006482_11.html

 

 

Paul Bernhardt
Application Development Consultant
BlackBerry
@PBernhardt

Did this answer your question? Please accept this post as the solution.
Found a bug? Report it to the Developer Issue Tracker
Contributor
Posts: 45
Registered: ‎04-11-2012
My Device: Z10 Limited Edition
My Carrier: 00201003883386

Re: how to capture keyboard input in cascades?

Thank you for reply.
could you please give me a sample of how to listen to key pressed

I already saw this page. code mentioned in the page assumes that there is an explicit loop

while this not the case in QT/C++

if there is a quick example, it will be better.

thank you
When you are young, work to learn. Not to earn !
Retired
Posts: 749
Registered: ‎12-16-2008
My Device: BlackBerry Z30
My Carrier: Bell

Re: how to capture keyboard input in cascades?

You will need to set up a loop to handle it though, as that is how BPS works. Basically just put the while loop into it's own thread, and leave out the bits about rendering, and then handle the screen event and screen_val (the key pressed) however you need to.

Paul Bernhardt
Application Development Consultant
BlackBerry
@PBernhardt

Did this answer your question? Please accept this post as the solution.
Found a bug? Report it to the Developer Issue Tracker
Contributor
Posts: 36
Registered: ‎11-22-2011
My Device: Playbook
My Carrier: na

Re: how to capture keyboard input in cascades?

[ Edited ]

This doesn't seem to work. I have set up an event loop in its own thread to capture bps events, but the keyboard key press events don't ever get fired. Is there something that needs to done? I did notice in the docs that you need to subscribe to screen events with a screen context to get key press events. Do we maybe need to use the cascades application screen context? If so, how do you obtain that?

Developer
Posts: 825
Registered: ‎10-16-2012
My Device: Red Z10
My Carrier: Rogers

Re: how to capture keyboard input in cascades?

screen.h

 

If you build a screenService.cpp & .hpp similar to how the virtualKeyboardService is setup in Smart Signals

that should allow you to listen for & interact with screen events

 

I needed to interact with the Navigator so I took VirtualKeyboardService.cpp & renamed anything keyboard related to functions & data types included in navigator.h & that worked like a charm for me and also helped me understand how to interact with the native API's

Contributor
Posts: 36
Registered: ‎11-22-2011
My Device: Playbook
My Carrier: na

Re: how to capture keyboard input in cascades?

Thank-you for the rely. Navigator and virtual keyboard events such as when the keyboard is shown work fine. It is only screen events such as key presses, multi-touch, and mouse events that don't get caught because they rely on a valid screen context. I have no problem with any events that don't use a screen context. Not sure why key press events are classified as screen events, but the only way I gran get them to fire is to have a foreign window control that is above cascades, but that keeps you from using cascades overlays and gestures.

Retired
Posts: 749
Registered: ‎12-16-2008
My Device: BlackBerry Z30
My Carrier: Bell

Re: how to capture keyboard input in cascades?

You could have the foreign window control request focus whenever the user is done using any part of the rest of your UI

Paul Bernhardt
Application Development Consultant
BlackBerry
@PBernhardt

Did this answer your question? Please accept this post as the solution.
Found a bug? Report it to the Developer Issue Tracker
Contributor
Posts: 16
Registered: ‎04-28-2013
My Device: PlayBook
My Carrier: none

Re: how to capture keyboard input in cascades?

Have a look at KeyListener in the 10.1.  http://developer.blackberry.com/cascades/reference/bb__cascades__keylistener.html

 

You might also want to use shortcuts:

http://developer.blackberry.com/cascades/reference/bb__cascades__shortcut.html

_______________________________________________________
C++, 3D OpenGL and Game Programming video tutorials:
http://www.MarekKnows.com
Play my free games:
Zing: http://appworld.blackberry.com/webstore/content/27406036
Jewel Thief: http://appworld.blackberry.com/webstore/content/29105889