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: 15
Registered: ‎11-10-2009
My Device: Not Specified
Accepted Solution

PictureScrollField + EyelidFieldManager + ToolbarManager focusing problems

Hi all,

 

I am having issue with using PictureScrollField along with EyelidFieldManager and ToolbarManager.

 

Take a look at the screenshot of simulator.

 

In the middle I have PictureScrollField, which has to scroll images, that are scaled to screen width and height, so PictureScrollField takes all screen space.

 

I also have EyelidFieldManager which includes a ToolbarManager in the bottom. It pops up on top of the PictureScrollField and It goes away   after 2 seconds. All these are perfect , however, my problem  is that no matter what I do, the toolbar is not responding to clicks/touches.

Seems like PictureScrollField hijacks the focus.

 

If I make PictureScrollField shorter, preventing the EyelidFieldManager overlap  the PictureScrollField, then ToolbarManager is working, otherwise it is not working (shortening of picture filed defeats the purpose of the Eyelid).

 

Is there a way of switching the focus from PictureScrollField to the ToolbarManager?

 

2919i57217E59D8133BFE

Developer
Posts: 15
Registered: ‎11-10-2009
My Device: Not Specified

Re: PictureScrollField + EyelidFieldManager + ToolbarManager focusing problems

Hi all, :-)

 

I have tried number of different things, such as playing around with setFocus(), overriding navigationMovement() and onFocus(), and implementing focusChanged(), but as soon as PictureScrollField gets the focus it never lets it go.

 

I think I should add some more details to this post to make things little bit more clear.

 

I am using 6.0 SDK for this project and developing in Eclipse.

 

The main screen includes an EyelidFieldManager. In the middle of the EyelidFieldManager I added PictureScrollField that takes all available screen space. In the bottom of the EyelidFieldManager I have ToolbarManager with 5 icons. Bottom part appears on start up or user input, and disappears after 2 seconds, and when it is visible it goes on top of the PictureScrollField. The problem is that when EyelidFieldManager is visible, none of the toolbar icons are clickable. However, PictureScrollFiled never looses it's focus, even when I am trying to click the toolbar or navigate away from PcitrueScrollField using trackball.

 

Is there a way to request focus for the toolbar, or bottom part of the EyelidFieldManager when it becomes visible ? 

 

Thanks

Developer
Posts: 723
Registered: ‎03-12-2009
My Device: Playbook

Re: PictureScrollField + EyelidFieldManager + ToolbarManager focusing problems

Check your virtual extent.   Seems like the virtual extent is not being set properly.

Developer
Posts: 15
Registered: ‎11-10-2009
My Device: Not Specified

Re: PictureScrollField + EyelidFieldManager + ToolbarManager focusing problems

Thanks for your reply.

I am not sure which field I should extend and set it's extent to.

To demonstrate the problem I created a hybrid project, combining two example projects: PictureScrollField and EyelidFieldManager. I am putting the PictureScrollField in the bottom, so when eyelid is visible it will go over the PictureScrollField. When this happens, toolbar is not clickable. Code is as follows:

 

 

package com.rim.samples.device.ui.eyelidfielddemo;

import net.rim.device.api.system.Bitmap;
import net.rim.device.api.system.EncodedImage;
import net.rim.device.api.ui.Color;
import net.rim.device.api.ui.UiApplication;
import net.rim.device.api.ui.VirtualKeyboard;
import net.rim.device.api.ui.container.MainScreen;
import net.rim.device.api.ui.decor.BackgroundFactory;
import net.rim.device.api.ui.extension.component.PictureScrollField;
import net.rim.device.api.ui.extension.component.PictureScrollField.HighlightStyle;
import net.rim.device.api.ui.extension.component.PictureScrollField.ScrollEntry;
import net.rim.device.api.ui.extension.container.EyelidFieldManager;
import net.rim.device.api.ui.image.Image;
import net.rim.device.api.ui.image.ImageFactory;
import net.rim.device.api.ui.toolbar.ToolbarButtonField;
import net.rim.device.api.ui.toolbar.ToolbarManager;
import net.rim.device.api.util.StringProvider;

public final class EyelidFieldDemo extends UiApplication
{
public static void main(String[] args)
{
UiApplication app = new EyelidFieldDemo();
app.enterEventDispatcher();
}


public EyelidFieldDemo()
{
pushScreen(new EyelidFieldDemoScreen());
}


public final class EyelidFieldDemoScreen extends MainScreen
{
private static final int NUM_ENTRIES = 4;
private static final String CALL_OUT_TEXT = "Call-out ";

private EyelidFieldManager _eyelidFieldManager;
private Bitmap[] _bitmaps;
private PictureScrollField _pictureScrollField;
/**
* Creates a new EyelidFieldDemoScreen object
*/
public EyelidFieldDemoScreen()
{
super(NO_VERTICAL_SCROLL);

_eyelidFieldManager = new EyelidFieldManager();

// Change the display time from the default 1.2s
_eyelidFieldManager.setEyelidDisplayTime(2000);

// Initialize an array of Bitmaps
_bitmaps = new Bitmap[NUM_ENTRIES];
_bitmaps[0] = Bitmap.getBitmapResource("berry.jpg");
_bitmaps[1] = Bitmap.getBitmapResource("logo_blue.jpg");
_bitmaps[2] = Bitmap.getBitmapResource("logo_black.jpg");
_bitmaps[3] = Bitmap.getBitmapResource("building.jpg");

// Initialize an array of scroll entries
ScrollEntry[] entries = new ScrollEntry[NUM_ENTRIES];
entries[0] = new ScrollEntry(_bitmaps[0], "BlackBerry", CALL_OUT_TEXT + 1);
entries[1] = new ScrollEntry(_bitmaps[1], "Blue logo", CALL_OUT_TEXT + 2);
entries[2] = new ScrollEntry(_bitmaps[2], "Black logo", CALL_OUT_TEXT + 3);
entries[3] = new ScrollEntry(_bitmaps[3], "Building", CALL_OUT_TEXT + 4);

// Initialize the picture scroll field
_pictureScrollField = new PictureScrollField(150, 100);
_pictureScrollField.setData(entries, 0);
_pictureScrollField.setHighlightStyle(HighlightStyle.ILLUMINATE);
_pictureScrollField.setHighlightBorderColor(Color.RED);
_pictureScrollField.setBackground(BackgroundFactory.createSolidBackground(Color.LIGHTBLUE));
_pictureScrollField.setLabelsVisible(true);
_pictureScrollField.setLensShrink(0.4f);
_eyelidFieldManager.add(_pictureScrollField, 0, 350);

// Create Toolbar and add it to the bottom of eyelid
ToolbarManager toolbarMan = new ToolbarManager();
Image img = getImage("home.png");
StringProvider title = new StringProvider("Home");
ToolbarButtonField toolbarButton = new ToolbarButtonField(img, title);
toolbarMan.add(toolbarButton);
_eyelidFieldManager.addBottom(toolbarMan);

add(_eyelidFieldManager);

// Disable virtual keyboard so it doesn't obscure bottom eyelid
VirtualKeyboard keyboard = getVirtualKeyboard();
if( keyboard != null )
{
keyboard.setVisibility(VirtualKeyboard.IGNORE);
}
}

/**
* @see MainScreen#onSavePrompt()
*/
public boolean onSavePrompt()
{
// Suppress the save dialog
return true;
}
}

private static EncodedImage getEncodedImage(String name) {
return EncodedImage.getEncodedImageResource(name);
}

private static Image getImage(String name) {
return ImageFactory.createImage(getEncodedImage(name));
}
}

 

Below is the screenshot after running this code. Home button is not reacting on touch event. Instead I am able to scroll the pictures, even when my touch event is over the toolbar.

 

2927iAA601613DE392373

Developer
Posts: 723
Registered: ‎03-12-2009
My Device: Playbook

Re: PictureScrollField + EyelidFieldManager + ToolbarManager focusing problems

I would look inside EyelidFieldManager

Developer
Posts: 15
Registered: ‎11-10-2009
My Device: Not Specified

Re: PictureScrollField + EyelidFieldManager + ToolbarManager focusing problems

I think I got this working.

 

I extended EyelidFieldManager and overrode touchEvent(TouchEvent message) method returning false. This fixes the problem, and I toolbar accepts touch events when Eyelid is closed.

 

Seems like EyelidFieldManager's onTouch method returns true or something like that...???? Please post here if there is better explanation to this.

 

Thanks dnepr for your replies.