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
Highlighted
Developer
Posts: 103
Registered: ‎12-01-2009
My Device: Not Specified
Accepted Solution

Focus Handling of HorizontalFieldManager

Hi,

 

I am trying to make a horizontalfieldManager focusable. That is, if user clicks on a horizontal Field Manager then to do some specific event handling. I used the following code:

 

package com.coloredmanager;

import net.rim.device.api.system.Display;
import net.rim.device.api.ui.container.MainScreen;
import net.rim.device.api.ui.container.HorizontalFieldManager;
import net.rim.device.api.ui.Color;
import net.rim.device.api.ui.Field;
import net.rim.device.api.ui.FieldChangeListener;
import net.rim.device.api.ui.Graphics;
import net.rim.device.api.ui.UiApplication;
import net.rim.device.api.ui.component.ButtonField;
import net.rim.device.api.ui.*;

public class ColoredManager extends MainScreen{

public ColoredManager()
{
    HorizontalFieldManager top = new HorizontalFieldManager(Field.FOCUSABLE){
        protected void sublayout(int width, int height)
        {
            width = Display.getWidth();
            height = Display.getHeight()/2;
            super.sublayout(width, height);
            setExtent(width, height);
           
        }
        protected void subpaint(Graphics graphics)
        {
            graphics.setBackgroundColor(Color.BLACK);
            graphics.clear();
            super.subpaint(graphics);
        }
       
    };


ButtonField btn = new ButtonField("submit");
add(top);
top.add(btn);

FocusChangeListener listenerSubmit = new FocusChangeListener() {
    public void focusChanged(Field field, int context) {
    if(context == FOCUS_CHANGED)
        {UiApplication.getUiApplication().pushScreen(new FinalScreen());   
    }
    }
    };



top.setFocusListener(listenerSubmit);
}

}

 

But when i click on area of horizontal manager my new screen is not appearing.

pls suggest me!!

 

Thanks,

Rahul

BlackBerry Development Advisor
Posts: 15,882
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: Focus Handling of HorizontalFieldManager

Manager aren't designed to handle focus in this manor.  You could create a custom Field class that takes up all space possible within a manager, which does not draw anything on the screen to handle your focus change events.  However, this wouldn't work "behind" your button (the edges around it).

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Developer
Posts: 103
Registered: ‎12-01-2009
My Device: Not Specified

Re: Focus Handling of HorizontalFieldManager

Hi,

 

Thanks for the reply.

I have the requirement of displaying some text images as a group.

I thought of displaying them in a horizontal manager and then handle focus event of horizontal Manager. But as u said, since it is not possible.

How should i proceed to handle this requirement??

 

Thanks,

Rahul

Developer
Posts: 193
Registered: ‎04-27-2009
My Device: Not Specified

Re: Focus Handling of HorizontalFieldManager

you can use touchEvent() method.

BlackBerry Development Advisor
Posts: 15,882
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: Focus Handling of HorizontalFieldManager

What do you want to do as a group?  You could change the background colour of the HorizontalFieldManager if any of the fields within it are selected to make it appear that all have been selected.

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Developer
Posts: 103
Registered: ‎12-01-2009
My Device: Not Specified

Re: Focus Handling of HorizontalFieldManager

I want to display some texts and some images as a group in bar. And when user clicks on the bar( at any point on the bar, say on image or text) then it should move to next screen.

 

I am thinking on placing those items in a horizontalfieldmanager and then somehow handle the click on that manager.

 

How can i do this??

 

Thanks,

Rahul

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

Re: Focus Handling of HorizontalFieldManager

Sorry, you seem to be repeating the same question but you have already accepted that managers can't do this.

 

Managers are not intended to handle click events, they are containers for Fields.  So the Fields you add to this Manager could handle this for you.

Developer
Posts: 103
Registered: ‎12-01-2009
My Device: Not Specified

Re: Focus Handling of HorizontalFieldManager

Thanks for the reply!!

 

If we can not handle click event on horizontalFieldManager, then how can i create a tab with texts and images. And even if i click any where on tab, then i should move to next screen.

 

Thanks,

Rahul

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

Re: Focus Handling of HorizontalFieldManager

[ Edited ]

"how can i create a tab with texts and images. And even if i click any where on tab, then i should move to next screen"

 

Try this.

 

Have at least 1 focusable FIeld in the HorizontalFieldManager and process clicks on that Field to take you to the next screen.

 

You might be interested in this Thread which demonstrates what Mark Sohm suggested you do, in making the background of the HorizontalFieldManager change to indicate focus:

http://supportforums.blackberry.com/t5/Java-Development/Creating-a-highlight-effect-on-a-horizontalF...

 

This Thread to, might be of interest:

http://supportforums.blackberry.com/t5/Java-Development/How-to-scroll-a-screen-to-always-have-the-fi...

Developer
Posts: 103
Registered: ‎12-01-2009
My Device: Not Specified

Re: Focus Handling of HorizontalFieldManager

Hey thanks for the reply!!

 

I searched the forum and found threads which suggest that i can customize lists for this requirement.


http://supportforums.blackberry.com/t5/Java-Development/Custom-ListField-row-with-images-and-text/m-...

 

I tried this methid also, but i am getting the problem that my first row in list is not set with the height as mentioned in setRowHeight().

 

How can i solve this issue??

 

Thanks,

Rahul