View Single Post
Old 02-26-2009, 10:42 PM   #1 (permalink)
icess
New Member
 
Join Date: Feb 2009
Model: 8320
PIN: N/A
Carrier: china mobile
Posts: 9
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default scroll a big field?

Please Login to Remove!

I use a custome field. the field height is larger than the screen height.

I override the navigationMovement and getFocusRect method to implement the focus movement inside the field. now i have a problem, when the focus rect is outside the view, the screen do not scroll, so how to implement this behave. just like the RichTextField , when the focus rect is outside the view, the screen will scroll to display the next focus rect.

any help? thanks!

Code:
 public void getFocusRect(XYRect rect) {
		rect.set(0, verticalPadding+headerHeight+rowHeight*selectedRowIndex, getWidth(), rowHeight);
	}

protected boolean navigationMovement(int dx, int dy, int status, int time) {
		 
		if ((status&KeypadListener.STATUS_FOUR_WAY) == KeypadListener.STATUS_FOUR_WAY) { 
			if (dx > 0) {
				 
				xoffset -= 10;
				invalidate();
				return true;
			} else if (dx < 0) {
				 
				xoffset += 10;
				invalidate();
				if(xoffset > 0) {
					xoffset = 0;
					return true;
				}
			} else if (dy > 0) {
				 
				if(selectedRowIndex < this.rowNum) {
					selectedRowIndex ++;
					if(selectedRowIndex == rowNum) {
						selectedRowIndex = rowNum-1;
						return false;
					}
					invalidate();
					return true;
				}
			} else if (dy < 0) {
				 
				if(selectedRowIndex > 0) {
					selectedRowIndex --;
					if(selectedRowIndex < 0) {
						selectedRowIndex = 0;
						return false;
					}
					invalidate();
					return true;
				}
			}
		}  
		return super.navigationMovement(dx, dy, status, time);
	}
Offline   Reply With Quote