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: 248
Registered: ‎11-23-2009
My Device: Not Specified

How to setfocus on main menu item from my app?

Hi All

 

i have x and y coordinates.

 

i want to set focus at these coordinates on the main menu screen of my device.

 

Basically these coordinates reflect the location of one of the menu icons (say "Messages") in the main menu.

 

i didnt know how to go about it but this is what i have tried so far....

 

/* 

"BBReadFile" is the name of the application. I push it to the background so that i can see menu screen

*/

BBReadFile.getUiApplication().requestBackground();

/*

now i am trying to set focus on one of the menu icons by providing co-ordinate values to the setfocus method

*/ 

setFocus(139,67,KeypadListener.STATUS_NOT_FROM_KEYPAD);

 

As expected it didnt work....i guess the setfocus() is still focussing on the application and not on the menu screen.

 

Can someone please guide me with this? i tried googling but didnt get much.....

 

Thanks,

Saket

 

 

Developer
Posts: 85
Registered: ‎05-03-2010
My Device: Not Specified

Re: How to setfocus on main menu item from my app?

Hi Saket,

Just wondering if by main menu you mean the main menu of your own application or some other menu?

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

Re: How to setfocus on main menu item from my app?

I too am confused by this question. Typically on a Blackberry the menu is obtained by pressing the Blackberry key.  The Menu is a popup screen that appears infront of your screen, so there is no need to push the application to the background. 

 

Can you please clarify the question. 

Developer
Posts: 248
Registered: ‎11-23-2009
My Device: Not Specified

Re: How to setfocus on main menu item from my app?

Hi All

 

Please allow me to clarify, by menu i am referring to the Blackberry's menu screen. The one you get when u click on the BlackBerry key. The menu has different icons like Messages, Options, Media, Games, Camera etc. You can scroll on these icons using the trackpad/trackball.

 

I hope i was able to clarify the menu which i want to set focus on. I would like that thru my application i am able to set focus on any of the Blackberry menu icons. As i mentioned earlier i have the x and y coordinates.

 

I tried the setfocus() method and passed the x and y coordinates but nothing happens? Please let me know what is the correct way of accomplishing this task.

 

Thanks,

Saket

Developer
Posts: 526
Registered: ‎05-17-2009
My Device: 9900

Re: How to setfocus on main menu item from my app?

From your application it is not possible to set the focus to a specific location on the default blackberry home screen (what you are referring to here). Once your application goes to the background you no longer have control, and unless you derived a hack by sending to the background, getting the active screen, then manager and then setting the focus im not sure its doable.

Like all of my posts
Developer
Posts: 19,612
Registered: ‎07-14-2008
My Device: Not Specified

Re: How to setfocus on main menu item from my app?

In BlackBerry terms, the screen you are referring to is more commonly referred to as the Home screen with the Application icons rather than a menu screen with menu items.  Menus mean something else entirely.

 

Like kylefowler, I am not aware of a standard way of achieving what you would like and also suspect that it would extremely difficult to hack this in any way. 

Developer
Posts: 248
Registered: ‎11-23-2009
My Device: Not Specified

Re: How to setfocus on main menu item from my app?

Okay

 

But please help me understand this.....

 

What is happening here:

 

//BBReadFile is the name of my app. I am pushing it to the background

 

BBReadFile.getUiApplication().requestBackground();

 

//What will be the result of the below line?

 

setFocus(139,67,KeypadListener.STATUS_NOT_FROM_KEYPAD);

 

does it mean that the setfocus() method is working within the scope of my application?

 

Secondly, i was able to generate a trackball click event which allows me to automatically click on the highlighted app icon on the home screen while my app runs in the background.

 

Now i just need a way to get the cursor on top of the desired icon before i invoke the click event....

 

A colleague of mine was able to achieve this on his Windows based handset, surely it must be possible on a BB as well.....i hope. Maybe i will see what logic he is using.......

 

Thanks,
Saket