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


Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.


Reply
Highlighted
Developer
Posts: 34
Registered: ‎08-11-2011
My Device: BlackBerry Bold
My Carrier: Axis

Setting Focus to A Field Based On Coordinates X & Y

[ Edited ]

Custom Pointer

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Hi, I want to create an arrow pointer like the one shown on the BrowserField. To do this, I'm using an AbsoluteFieldManager to layout the fields and also the arrow pointer itself. I have overridden the original navigationMovement method so that instead of moving focus to another field, it moves the arrow pointer's position and then repaints the entire screen.

 

The problem right now is, I don't know how to set focus to a field based on the coordinates of the arrow pointer.

 

I tried using:

setFieldWithFocus(getField(getFieldAtLocation(x, y))); 

before invalidating the screen, but that didn't seem to work.

 

Can somebody help me with this?

 

Thanks in advance.

Developer
Posts: 34
Registered: ‎08-11-2011
My Device: BlackBerry Bold
My Carrier: Axis

Re: Setting Focus to A Field Based On Coordinates X & Y

It seems the ButtonFields aren't receiving focus because they're placed within a HorizontalFieldManager. So when I try to get the Field at the specified coordinates using getFieldAtLocation(x,y), it returns the HorizontalFieldManager and not the ButtonField inside it.

 

I can get the ButtonFields to receive focus by using:

int index = hfm.getFieldAtLocation(x, y);

if (index > -1)
{
	Field f = hfm.getField(index);
	f.setFocus();
}
else
{
	nullField.setFocus();
}

But then I would have a problem if I wanted to select a Field placed within another manager within the HorizontalFieldManager.

 

Is there a way to get retrieve a non-manager field at a specified coordinate?

 

Thanks in advance.

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

Re: Setting Focus to A Field Based On Coordinates X & Y

Sorry, just a quick answer here that may be wrong.

 

You can keep if then Field you get back is a Manager or not.  if it is a manager, then you need to adjust the x and y according whereabouts that Manager actually starts, and then call getFieldAtLocation again. I think you should be able to do this recursively until you hit a real Field.

 

But you might find you do not in fact get a Field, because the user has hit outside the bounds of all fields.  Not sure how you want to handle that.