Welcome to the Official BlackBerry® Support Community Forums. This is your resource to discuss support topics with your peers, and learn from each other. New to the forum? Please visit the ‘Getting Started’ link below.
inside custom component

Java Development

Reply
Trusted Contributor
vijaytabhatt
Posts: 141
Registered: 03-22-2010

making bars click able in bar diagrams

hello,

 

i have gone through sample given in knowledge base article for bar diagram given at the link below,

http://supportforums.blackberry.com/t5/Java-Development/Create-graph-fields/ta-p/444968

 

can anyone please tell me is it possible to make individual bars in bar diagram click able?

 

Thanks,

Vijayta

Please use plain text.
Developer
Ted_Hopp
Posts: 1,287
Registered: 01-21-2009

Re: making bars click able in bar diagrams

For touch operation, you can make your custom field react to touch events and check the coordinates of the touch. For non-touch operation, you can maintain an internal model of the "current focus" (one of the bars) and react to navigation click events. (You also need to deal with several focus issues; see the documentation for Field.)




Solved? click "Accept as solution". Helpful? give kudos by clicking on the star.
Please use plain text.
Trusted Contributor
vijaytabhatt
Posts: 141
Registered: 03-22-2010

Re: making bars click able in bar diagrams

i understood your logic for touch screens but can you please explain for non-touch screens in detaili?

Please use plain text.
Developer
arkadyz
Posts: 2,146
Registered: 07-08-2009
My Carrier: various

Re: making bars click able in bar diagrams

Keep a "focused" bar index as the Field member and highlight it (the "focused" bar) somehow in your paint() override.  Change that index within navigationMovement() according to your logic (try to make it intuitive enough for the user) and invalidate() the field each time you adjust the index. Check that index in navigationClick() and act accordingly.

----------------------------------------------------------
please click 'Accept Solution' on posts that provide the solution to the question you've posted. Don't say "Thanks", press 'Like' button instead!
Please use plain text.
Developer
Ted_Hopp
Posts: 1,287
Registered: 01-21-2009

Re: making bars click able in bar diagrams

Here's a little more detail of what I was suggesting. I haven't looked at the sample code in the KB article you referenced, but let's take something like BarGraphField. I assume that it overrides the usual suspects: layout(), paint(), getPreferredWidth(), and getPreferredHeight(). These would probably not need to be changed. Instead, you would do the following:

  1. Add a member variable (let's call it focusBar) that is the index of the bar with the current focus, initially set to -1.
  2. Override isFocusable() to return true.
  3. Override drawFocus() or getFocusRect() to draw an outline around focusBar, so the user knows which bar is currently selected.
  4. Override onFocus() to give either the first or last bar focus, depending on the direction. Also override onUnfocus() to set focusBar to -1 again.
  5. Override both moveFocus() methods to change focusBar. (You may need to maintain additional variables about the geometry of the bars in order to do the drawing and focus moves.)

I may have left out some steps, but I think that covers it. It will take some experimenting to get everything right.




Solved? click "Accept as solution". Helpful? give kudos by clicking on the star.
Please use plain text.
Contributor
ashokjavasp
Posts: 21
Registered: 01-29-2010
My Carrier: NA

Re: making bars click able in bar diagrams

Hi,

 

I too facing the same issue on the bar / pie . Can u give me briefing on the same or some links / sample code

 

 

Thanks in advance.

Please use plain text.
Developer
peter_strange
Posts: 14,614
Registered: 07-14-2008

Re: making bars click able in bar diagrams

Please use plain text.