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: 468
Registered: ‎08-07-2009
My Device: Curve, Bold, Storm

ObjectChoiceField on Image Click

Hi All,

 

I am using Object choice field and an image.

 

I want to open ObjectChoiceField choices on the navigationclick event of an image.

 

How can i achieve this?  Plz help me.

 

 

 

Thanks and Regards

 

Ekansh

----------------------------------------------------------
feel free to press the kudos button on the left side to thank the user that helped you.
please mark posts as solved if you found a solution.
Developer
Posts: 468
Registered: ‎08-07-2009
My Device: Curve, Bold, Storm

Re: ObjectChoiceField on Image Click

Please someone help...

----------------------------------------------------------
feel free to press the kudos button on the left side to thank the user that helped you.
please mark posts as solved if you found a solution.
Developer
Posts: 1,055
Registered: ‎01-25-2009
My Device: BlackBerry Bold 9650/BlackBerry Torch 9800

Re: ObjectChoiceField on Image Click

[ Edited ]

You have an image that when pressed (trackball or screen) will pop open an ObjectChoiceField for the user to choose an option.

 

You'd need to use a BitmapField and add it to your screen. On navigationClick event, you would then pop an ObjectChoiceField in a dialog (a dialog is, after all, just another screen with some extra options).

 

If you just need to select a choice, on the navigationClick just use Dialog.ask (simplest way).

Jerome Carty - Follow jcarty on Twitter@jcarty | #webworks-dev / #BlackberryDev on irc.freenode.net | My Apps
Click "Accept as Solution" if post solved your original issue.. Give like/thumbs up if you feel post is helpful
Developer
Posts: 571
Registered: ‎04-11-2009
My Device: BB 10 Dev Alpha

Re: ObjectChoiceField on Image Click

Hi Ekansh,

 

I have not done it, but I think we can do it by on selection of the image we set focus on the objectchoicefield and with the help of Event Injection (EventInjector.TrackwheelEvent) you can apply THUMB_CLICK event to open this choice field.

 

Thanks & regards,

Kanak

Regards,
Kanak Sony
------------------------------------------------------------------------------------------
http://dodevelopnshare.wordpress.com/ | http://www.linkedin.com/profile/view?id=188131481&trk=tab_pro
Developer
Posts: 141
Registered: ‎02-10-2010
My Device: 9500

Re: ObjectChoiceField on Image Click

[ Edited ]

Use ObjectChoiceFiled with one element providing the layout width & height as desired and background set using setBackground. When the element gets clicked, reset the list to the options as desired using setChoices.

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

Re: ObjectChoiceField on Image Click

If the Event Injector method does not work, or you don't want to ask the user for permission for Input Simulation, you might try this method which I remember seeing in a previous forum entry.  I have not tried it myself.

 

Basically ask the ObjectChoiceField for its contextmenu.

ContextMenu cm = <objectChoiceField>,getContextMenu();

 

Then I think the default option in the Context menu is the one to 'Change Options', 

MenuItem mi = cm.getDefaultmenu();

 

So you run the default menu item. 

mi.run();

 

I would set Focus on the ObjectChoiceField first.

Developer
Posts: 468
Registered: ‎08-07-2009
My Device: Curve, Bold, Storm

Re: ObjectChoiceField on Image Click

Hi all, Thanx for replying.

 

2.pngIn this ALL is an objectChoiceField and arrow is a bitmapfield.

On click of an image, i want objectchoicefield to open.

 

I have tried the following code:  But its not working as expected

 

 objectSymbol = new ObjectChoiceField("",symbolStrings,0,Field.FIELD_LEFT)
{
protected void fieldChangeNotify(int context)
{
index = getSelectedIndex();
}
protected void layout(int width, int height)
{
width = SizeSpec.ChoiceWid;
height = SizeSpec.ChoiceHgt;
super.layout(width, height);
super.setExtent(width, height);
}
};


symbolImage = new BitmapField(downArrow.getBitmap(),BitmapField.FOCUSABLE)
{
protected boolean navigationClick(int status,int time)
{
objectSymbol.getContextMenu();
return true;
}
};


----------------------------------------------------------
feel free to press the kudos button on the left side to thank the user that helped you.
please mark posts as solved if you found a solution.
Developer
Posts: 19,612
Registered: ‎07-14-2008
My Device: Not Specified

Re: ObjectChoiceField on Image Click

In future when you say "not working as expected" can you tell us what it is doing? 

 

In this case I suspect nothing, because you have not used all the code I gave you. 

 

I suggest you review my post again, looking at all the code.

 

But before your put the code in your program, look carefully at what is going on so you understand what the processing is actually doing.  The code in your program should not be some magic incantation that you recite, You should understand it and what it is actually doing.  If you don't understand it, you will never figure out what to do if it doesn't work or breaks will you!