PDA

View Full Version : capturing touchevent of right most fields


renuka_anil
10-08-2009, 01:46 AM
Hi All,
Here is my code snippet.
int footerHeight = footerImage.getHeight();
footerManager = new HorizontalFieldManager(HorizontalFieldManager.NO_VERTICAL_SCROLL
| HorizontalFieldManager.NO_HORIZONTAL_SCROLL | HorizontalFieldManager.FOCUSABLE){
public void paint(Graphics graphics){
int partVal = Display.getWidth()/6;
int xPos = partVal;
if(btnExplore != null){
xPos = (partVal-btnExplore.getWidth())/2;
setPositionChild(btnExplore, xPos, 0);
}
if(btnSearch != null){
xPos = (partVal-btnSearch.getWidth()/2)+(partVal/2);
setPositionChild(btnSearch, xPos , 0);
}
if(btnFavourite != null){
xPos = (partVal-btnFavourite.getWidth()/2)+(partVal+(partVal/2));
setPositionChild(btnFavourite, xPos , 0);
}
if(btnPersonal!= null){
xPos = (partVal-btnPersonal.getWidth()/2)+((partVal*2)+partVal/2);
setPositionChild(btnPersonal, xPos, 0);
}
if(btnabout != null){
xPos = (partVal-btnabout.getWidth()/2)+((partVal*3)+(partVal/2));
setPositionChild(btnabout, xPos, 0);
}
if(btnExit != null){
xPos = (partVal-btnExit.getWidth()/2)+((partVal*4)+(partVal/2));
setPositionChild(btnExit, xPos, 0);
}
graphics.setColor(0x800000);
graphics.drawBitmap(0, 0, Display.getWidth(), footerHeight, footerImage, 0 , 0);
if(Container.isFirst == 0){
invalidate();
}
super.paint(graphics);
}

public void sublayout(int maxWidth, int maxHeight){
maxWidth = Display.getWidth();
maxHeight = footerHeight;
super.sublayout(maxWidth, maxHeight);
setExtent(maxWidth, maxHeight);
}

public int getPreferredWidth(){
return Display.getWidth();
}

public int getPreferredHeight(){
return footerHeight;
}
};

btnabout = new CustomButton(null, "MyApp/images/about-us.png", "MyApp/images/blueabout-us.png", false);

btnFavourite = new CustomButton(null, "MyApp/images/grey-star.png", "MyApp/images/blue.png", false);

btnExplore = new CustomButton(null, "MyApp/images/explore.png", "MyApp/images/blue-expore.png", false);

btnSearch = new CustomButton(null, "MyApp/images/grey-search.png", "MyApp/images/blue-search.png", false);

btnPersonal= new CustomButton(null, "MyApp/images/my-vows-grey.png", "MyApp/images/my-vows-blue.png", false);
btnExit = new CustomButton(null, "MyApp/images/exit.png", "MyApp/images/blue_exit.png", false);

footerManager.add(btnExplore);
footerManager.add(btnSearch);
footerManager.add(btnFavourite);
footerManager.add(btnPersonal);
footerManager.add(btnabout);
footerManager.add(btnExit);

I have added this manager in verticalFieldManager.

My problem is the last two button's touchevent is not get captured.

Like footer manager I have headerManager (HorizontalFieldManager). In that I placed one button at left corner and one at right corner. In that left corner button's touch event get captured but right button's touchevent is not getting captured.

In short.. the fields that I place at right corner (right 1/4 of screen) did not capture the touch event. This is happeing in device too.

can anybody please tell me what to do for this. I already posted my snippet.

Thanks.

renuka_anil
10-27-2009, 02:06 AM
Hi All,

I got solution for this..

In main manager in which footermanager is added i have handled touchEvent.

in that i have handled touchevent of all these fields manually.

Here is code

case TouchEvent.CLICK :
inde = getFieldAtLocation(event.getX(1),
event.getY(1));
if(inde != -1){
Field fm = getField(inde);
if(fm.equals(vfmMain)){
int index1 = vfmMain.getFieldAtLocation(event.getX(1),
event.getY(1));
// Ignore click events outside any fields
if (index1 == -1)
return true;
Field field = vfmMain.getField(index1);
if(field.equals(footerManager)){
//Container.isFooterManager = true;
int index2 = footerManager.getFieldAtLocation(event.getX(1),
event.getY(1));
if(index2 != -1){
Field field1 = footerManager.getField(index2);
if(field1.equals(btnExplore)){
btnExplore.touchEvent(event);
setFocusOnField();
return true;
}else if(field1.equals(btnFavourite)){
btnFavourite.touchEvent(event);
setFocusOnField();
return true;
}else if(field1.equals(btnSearch)){
btnSearch.touchEvent(event);
setFocusOnField();
return true;
}else if(field1.equals(btnabout)){
btnabout.touchEvent(event);
setFocusOnField();
return true;
}else if(field1.equals(btnMyVows)){
btnPersonal.touchEvent(event);
setFocusOnField();
return true;
}else if(field1.equals(btnExit)){
btnExit.touchEvent(event);
setFocusOnField();
return true;
}
}
}
}
}