BlackBerry Forums Support Community
              

Closed Thread
 
LinkBack Thread Tools
Old 04-20-2010, 04:35 AM   #1 (permalink)
Knows Where the Search Button Is
 
Join Date: Aug 2009
Model: 8800
PIN: N/A
Carrier: O2
Posts: 30
Post Thanks: 0
Thanked 0 Times in 0 Posts
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


Thread Tools

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

24 Gauge Solid 4-Conductor Indoor/Outdoor Telephone Wire
$4.99
24 Gauge Solid 4-Conductor Indoor/Outdoor Telephone Wire pictureNEW 960FT M27500-10TG3T14 Shielded Aircraft Wire Mil Spec 10AWG 3 Conductor 600V
$814.99
NEW 960FT M27500-10TG3T14 Shielded Aircraft Wire Mil Spec 10AWG 3 Conductor 600V picture26-Gauge Stranded 4-Conductor TELEPHONE WIRE 100 Foot Roll
$4.99
26-Gauge Stranded 4-Conductor TELEPHONE WIRE 100 Foot Roll pictureCooper Crouse-Hinds Arktite mating plug, 200 amp, four conductor, Cat # AP20457
$200.0
Cooper Crouse-Hinds Arktite mating plug, 200 amp, four conductor, Cat # AP20457 picture5 colors 15ft each Mil-Spec high temp wire cable 18 Gauge Tefzel M22759/16-18
$30.89
5 colors 15ft each Mil-Spec high temp wire cable 18 Gauge Tefzel M22759/16-18 picture






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