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
mohitsharma
Posts: 190
Registered: ‎10-22-2009
Accepted Solution

blackberry UI event delegation model

Hi m a beginner,

Can any body explain me how event delegation for UI components,  like in below scenario

 

____________________________

|             FullScreen                              |

|                                                              |

|   _______________________       |

|   |                                                   |      |

|   |               Manager                     |      |

|   |    _______________              |      |

|   |    |          Field               |            |      |

|   |    |                                  |            |      |

|   |    |_______________|            |      |

|   |______________________  |      |

|                                                              |

|___________________________ |

 

Here FullScreen is containing a Manager containing a Field.

If i do navigation click on screen or say a keychar event, who will be the first to receive the event

and who will be the last. Is there a way to stop this propagation in mid way?(like where i return true to consume event)

Its a basic question but will clear lots of concepts.

Awaiting your replies.

 

-----------------------------------------------------------------------------------
Please mark posts as solved if you found a solution. Press the kudos button to thank the user who helped you.
Please use plain text.
Developer
mreed
Posts: 1,041
Registered: ‎07-16-2008

Re: blackberry UI event delegation model

[ Edited ]

Off the top of my head:

 

navigationClick/trackwheelClick should go straight to the field with focus.

keychar/keyDown/etc will pass form the screen down to the field.

moveFocus will go from the screen down to the field.

navigationMovement will go straight to the field with focus.

 

In some scenarios you can prevent the event from continuing by not calling super. In others you should be able to return true (or 0 in the case of moveFocus) to stop the event.

 

Touch events get trickier...

Please use plain text.
Developer
kylefowler
Posts: 525
Registered: ‎05-17-2009
My Carrier: ATT

Re: blackberry UI event delegation model

Just working with this tonight. My screen has a verticalfieldmanager in it which is then filled with multiple cutsom managers.

protected boolean navigationClick(int status, int time)
	{
		final VerticalFieldManager f=(VerticalFieldManager)this.getFieldWithFocus();

		if(f.getFieldWithFocus() instanceof CustomManager)
		{
                }
	}

 

the first field that it gets is the verticalfieldmanager, and then if I do the f.getFieldWithFocus() i will get my custom manager. Hope that helps at all

 

Like all of my posts
Please use plain text.
Developer
mohitsharma
Posts: 190
Registered: ‎10-22-2009

Re: blackberry UI event delegation model

regarding navigation movement wont it switch focus from fields to fields in manager and then goes to screen.

-----------------------------------------------------------------------------------
Please mark posts as solved if you found a solution. Press the kudos button to thank the user who helped you.
Please use plain text.
Developer
mohitsharma
Posts: 190
Registered: ‎10-22-2009

Re: blackberry UI event delegation model

What I really want to know is whether there is a general aproach for this so that its easy to design components like bottom up approach or top down or focus field first or something like that. I could be easy to remember and keep in mind rather than experimenting and jumpingto your own conclusions.

Blackberry experts kindly shed your light on this topic.

-----------------------------------------------------------------------------------
Please mark posts as solved if you found a solution. Press the kudos button to thank the user who helped you.
Please use plain text.
Developer
mohitsharma
Posts: 190
Registered: ‎10-22-2009

Re: blackberry UI event delegation model

Some of my obseravations regarding navigationClick

 

it first goes to Screen

then if inside Screen's navigationClick 

 if you return true it will be  consumed there and it wont propagate down to manager and fields and

 if you return false then it is not consumed and show a context menu and dont propagate down to manager and fields.

 if you return super.navigationClick then it is propagated down.

 

Hope that helps some of the guys out there.

 

everybody is welcomed for there some generic explainations.

 

-----------------------------------------------------------------------------------
Please mark posts as solved if you found a solution. Press the kudos button to thank the user who helped you.
Please use plain text.