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
JoVinz
Posts: 255
Registered: ‎05-03-2012
My Device: 9930
My Carrier: Vodafone

Popup menu is shown when touched on blank screen

When i touch on blank part of the screen, popup menu is displayed in touch devices. How should i prevent this? I have searched a lot. but didnt get proper solution.

Please use plain text.
Developer
simon_hain
Posts: 15,806
Registered: ‎07-29-2008
My Device: Z10 LE
My Carrier: O2 Germany

Re: Popup menu is shown when touched on blank screen

this is a default behavior.
maybe overwrite touchEvent and return true unless you want it handled.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Please use plain text.
Developer
pankajace12
Posts: 192
Registered: ‎04-30-2011
My Device: Software
My Carrier: Airtel

Re: Popup menu is shown when touched on blank screen

HI JoVinz,

There is focus issue. Can u please share ur code?

I have also face this.

Thanks
Please use plain text.
Developer
JoVinz
Posts: 255
Registered: ‎05-03-2012
My Device: 9930
My Carrier: Vodafone

Re: Popup menu is shown when touched on blank screen

I overwritten touchEvent of a screen and return true but results in nothing is touchable. How can i identify blank part of screen(When i touch on the screen how do i identify field is present or not where i touched. )
Please use plain text.
Developer
JoVinz
Posts: 255
Registered: ‎05-03-2012
My Device: 9930
My Carrier: Vodafone

Re: Popup menu is shown when touched on blank screen

protected boolean touchEvent(TouchEvent message)
{
return true;
};
Please use plain text.
Developer
simon_hain
Posts: 15,806
Registered: ‎07-29-2008
My Device: Z10 LE
My Carrier: O2 Germany

Re: Popup menu is shown when touched on blank screen

you can get the x/y coordinates from the touchevent and check with http://www.blackberry.com/developers/docs/7.1.0api/net/rim/device/api/ui/Screen.html#getFieldAtLocat... if there is a field.
did not try this, but in theory it should work.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Please use plain text.
Developer
JoVinz
Posts: 255
Registered: ‎05-03-2012
My Device: 9930
My Carrier: Vodafone

Re: Popup menu is shown when touched on blank screen

[ Edited ]

I have lot of fields on screen. Also its not fixed that where will be blank space. It depends on how much data is getting from server. so finding out x and y will be too difficult.

Please use plain text.
Developer
kanaksony
Posts: 571
Registered: ‎04-11-2009
My Device: BB 10 Dev Alpha

Re: Popup menu is shown when touched on blank screen

Hi,  We had also same problem. We handled it using below :

 

private boolean isAtFocusableLocation(Field fld, int x, int y) {
  while (fld instanceof Manager) {  
   Manager m = (Manager) fld;
   x = x - (m.getContentLeft() - m.getHorizontalScroll());
   y = y - (m.getContentTop() - m.getVerticalScroll());   
   int f = m.getFieldAtLocation(x, y);
   if(f >= 0) {
    fld = m.getField(f); 
   } else {
    fld = null;
    break;
   }
  }
  return fld == null ? false : fld.isFocusable();
 }

 

protected boolean touchEvent(TouchEvent event) {
	if(event.getEvent() == TouchEvent.CLICK) {
		if(isAtFocusableLocation(getMainManager(), event.getX(1), event.getY(1))) {
			return true;
		}
		else {
			return false;
		}
	}
  return super.touchEvent(event);
}

 

Hope it helps...

Regards,
Kanak Sony
------------------------------------------------------------------------------------------
http://dodevelopnshare.wordpress.com/ | http://www.linkedin.com/profile/view?id=188131481&trk=tab_pro
Please use plain text.
Developer
JoVinz
Posts: 255
Registered: ‎05-03-2012
My Device: 9930
My Carrier: Vodafone

Re: Popup menu is shown when touched on blank screen

[ Edited ]

Thanks a lot. Just reverse the condition in touchEvent()

if(isAtFocusableLocation(getMainManager(), event.getX(1), event.getY(1))) {
return false;
}
else {
return true;
}

 This will work in manager where there are no fields. But doesnt work for totally blank part of the screen.

Please use plain text.