BlackBerry Forums Support Community
              

Closed Thread
 
Thread Tools
Old 04-20-2010, 04:35 AM   #1
niceonedave
Knows Where the Search Button Is
 
Join Date: Aug 2009
Model: 8800
PIN: N/A
Carrier: O2
Posts: 30
Default How to properly handle focus traversal in custom field

Please Login to Remove!

I have implemented a custom field by extending the Manager class. The field is quite simple, it consists of a label and two check boxes, yes and no. The fields are laid out so that the label is on the left and uses as much space as it can while still allowing room for the check boxes which are positioned next to each other at the right and vertically centred compared to the label (if it spans more than one line). So it looks like this:

This is a question? O Yes O No

Everything is fine so far in terms of laying out the fields. But now I am trying to handle focus traversal. First of all the default behaviour when the user scrolls up or down is to move between the yes and no options. I want to move to the next field above or below when up or down is pressed, so I did this:

Code:
protected int moveFocus(int amount, int status, int time) {
	if (status == 537001984 || status == -1610481664) { // Up or down was pressed
		// Don't move focus between yes and no when up or down is pressed.
		return amount;
	}
	return super.moveFocus(amount, status, time);
}
And that seems to work.

The next thing I would like to do is to remember which option last had the focus when the field loses focus, then on gaining focus again (regardless of which direction the focus comes from) set this field to have the focus. I tried overriding onUnfocus and onFocus so that onUnfocus I note which field was focussed then onFocus setFocus to that field. But I get a StackOverflowError, I guess because the call to setFocus on a field within the manager actually calls onFocus for the manager itself again??

So does anyone know how I should be doing this? I checked the DateField and it has the exact behaviour I am looking for, i.e. it remembers if you were last on the day, month or year field and sets this field to focus when the field itself gets the focus.
Offline  
Closed Thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


Schneider Electric Energy Server EBX510 Server For Energy Management- picture

Schneider Electric Energy Server EBX510 Server For Energy Management-

$4350.00



FANUC Server Driver A06B-6077-H111 picture

FANUC Server Driver A06B-6077-H111

$2158.86



SXWAUTSVR10001 Schneider electric AUTOMATION SERVER BAGNET/LO picture

SXWAUTSVR10001 Schneider electric AUTOMATION SERVER BAGNET/LO

$350.00



Server Book for Waitress Book OrganizerUpgraded 9 Pockets PU Leather Waiter W picture

Server Book for Waitress Book OrganizerUpgraded 9 Pockets PU Leather Waiter W

$11.73



For DELL T140 Tower Server Motherboard 00RG5V picture

For DELL T140 Tower Server Motherboard 00RG5V

$300.00



Lot of 6 Server Syrup Flavoring Manual Pumps Stainless with Plastic Containers picture

Lot of 6 Server Syrup Flavoring Manual Pumps Stainless with Plastic Containers

$150.00







Copyright © 2004-2016 BlackBerryForums.com.
The names RIM © and BlackBerry © are registered Trademarks of BlackBerry Inc.