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


Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.


Reply
Developer
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.

Developer
Posts: 17,025
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
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
Developer
Posts: 209
Registered: ‎04-30-2011
My Device: BlackBerry Z10
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
Developer
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. )
Developer
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;
};
Developer
Posts: 17,025
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
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
Developer
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.

Developer
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
Developer
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.