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: 39
Registered: ‎07-21-2008
My Device: Many
My Carrier: Many

Detect Virtual (touch) Keyboard SurType vs multitap

Hi,

 

I got an application with api 4.7.0 with a lot of drawing and little text input. So, I'm using pure midlet canvas.

 

I need to know if the user set a SurType or multipad keyboard (in order to emulate the multi tap behavior).

 

I tried with Keypad.getHardwareLayout(), but there is only one const HW_LAYOUT_TOUCHSCREEN_12. (in add, the emulator never return it)

 

How can I detect the "portrait view keyboard" layout?

 

thanks in advance,

 

Christophe

Developer
Posts: 178
Registered: ‎07-29-2008
My Device: Not Specified

Re: Detect Virtual (touch) Keyboard SurType vs multitap

getHardwareLayout() isn't returning HW_LAYOUT_TOUCHSCREEN_24 for SureType?  that should be the result, otherwise i think its a bug.

 

http://www.blackberry.com/developers/docs/4.7.0api/net/rim/device/api/ui/Keypad.html#HW_LAYOUT_TOUCH...

 

 

 

 

Highlighted
Developer
Posts: 16,992
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Detect Virtual (touch) Keyboard SurType vs multitap

you can detect suretype and multitap by analyzing the context menu items of a field. a bit of a hack but works Smiley Happy
----------------------------------------------------------
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: 178
Registered: ‎07-29-2008
My Device: Not Specified

Re: Detect Virtual (touch) Keyboard SurType vs multitap

wait what?

 

Now i'm interested.

Developer
Posts: 16,992
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Detect Virtual (touch) Keyboard SurType vs multitap

field has a method getContextMenu.
ContextMenu has a method getItems() (which is not documented in the API, no clue why. just discovered it now, sometimes i just toy around with eclipse...)
using contextmenu.getSize() you can iterate the MenuItem objects.
Set the locale to english if it is not.
MenuItem has a toString method that gives you the localized name of the menu item. as the locale is english you can compare the menu items against their english names, "enable multitap" and "enable suretype" (out of my head, make sure to doublecheck).
set the locale to its old value (if it was changed)

as MenuItems happen to have a run method you can even execute these items, all you need is a reference to a field, manager or screen Smiley Happy

i should add a "hacking blackberry" section to the development book Smiley Very Happy

getHardwareLayout() would be a lot simpler - if it would work.
----------------------------------------------------------
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: 178
Registered: ‎07-29-2008
My Device: Not Specified

Re: Detect Virtual (touch) Keyboard SurType vs multitap

now that is a kudo worthy hack.

 

Now if only it was internationalizable.

Developer
Posts: 16,992
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Detect Virtual (touch) Keyboard SurType vs multitap

it is working on all devices as all devices have english language support.
you change the locale to "en", compare the menu items and switch the language back.

see net.rim.device.api.i18n.Locale, especially getCode(), getDefault(), setDefault(newLocale)
----------------------------------------------------------
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: 39
Registered: ‎07-21-2008
My Device: Many
My Carrier: Many

Re: Detect Virtual (touch) Keyboard SurType vs multitap

Thanks for the interesting reply,

About the return value of the getHardwareLayout(), I made more test and I think it return the last displayed kb (not the one that will be display on this screen).

About the context menu hack, this is an interesting one but this is not an option for me, since I do not use the BB/MIdlet Items but my own (I use pur Midlet canvas).

I will see If I can create a form and use this trick anyway.



New Developer
Posts: 13
Registered: ‎03-03-2009
My Device: Not Specified

Re: Detect Virtual (touch) Keyboard SurType vs multitap

Unfortunately, this method seems to be removed from some of the APIs (the one I'm compiling against is 4.5.0).

 

Any better suggestion?