03-10-2010 05:10 PM
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.
Solved! Go to Solution.
03-10-2010 05:59 PM - edited 03-10-2010 06:00 PM
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...
03-10-2010 11:51 PM
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
03-11-2010 12:34 AM
regarding navigation movement wont it switch focus from fields to fields in manager and then goes to screen.
03-11-2010 12:57 AM
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.
03-11-2010 02:12 AM
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.