I have created a ButtonField & a BitmapField like..
public class MyCanvas extends MainScreen implements FieldChangeListener
{
HorizontalFieldManager hfm;
private Bitmap startBitmap;
private BitmapField startBitmapField;
private ButtonField okButton;
MyCanvas()
{
hfm = new HorizontalFIeldManager();
startBitmap = Bitmap.getBitmapResource("start.png");
startBitmapField = new BitmapField(startBitmap);
startBitmapField.setChangeListener(this);
hfm.add(startBitmapField);
okButton = new ButtonField("Ok", ButtonField.CONSUME_CLICK | ButtonField.NEVER_DIRTY);
okButton.setChangeListener(this);
hfm.add(okButton);
}
public void fieldChanged(Field field, int context)
{
if(field == startBitmapField)
{
System.out.println("Touched START...");
}
else if(field == okButton)
{
System.out.println("Touched Ok...");
}
}
}
But the ButtonField or BitmapField click is not happening in Blackberry 4.7 simulator.
I want to build it for Blackberry Storm so I m using Blackberry 4.7
How to handle click/touch events for ButtonField & BitmapField for Blackberry Storm?
I m creating the ButtonField & BitmapFields as
okButtonField = new ButtonField("Ok", BitmapField.HIGHLIGHT_SELECT | BitmapField.FOCUSABLE);
startBitmapField = new BitmapField(startBitmap, BitmapField.HIGHLIGHT_SELECT | BitmapField.FOCUSABLE);
Its working with..
protected boolean touchEvent(TouchEvent event)
{
switch( event.getEvent() )
{
case TouchEvent.DOWN: ........
return true;
case TouchEvent.MOVE: .......
return true;
case TouchEvent.UP: ........
return true;
case TouchEvent.CLICK:
if(deleteButton.isFocus())
{
System.out.println("Touched DEL ..........");
}
else if(okButton.isFocus())
{
System.out.println("Touched OK ..........");
}
else if(startBitmapField.isFocus())
{
System.out.println("Touched START ..........");
}
return true;
}
return false;
}
but everytime the same button is invoked which is having focus.
Means if "Ok" button is having focus then even though u clicked on "Delete" button "Ok" button is called.
So how to change the focus on Button Click? means whichever ButtonField or BitmapField is clicked, should get the focus?
is there any method to check "button.isClicked() like button.isFocus() " ?