BlackBerry Forums Support Community
              

Closed Thread
 
Thread Tools
Old 07-22-2009, 03:10 AM   #1
ComputerWolf
Knows Where the Search Button Is
 
ComputerWolf's Avatar
 
Join Date: Jul 2009
Model: 8310
PIN: N/A
Carrier: AT&T
Posts: 19
Default 4.6 Scroll Field Problem

Please Login to Remove!

I have the following code which is a custom RichTextField. Many of these are placed in a VerticalFieldManager and scrolled through. In OS 4.5 and 4.7 when one of the fields gets focus and is highlighted, the entire field is moved onto the screen. However in 4.6.0, only 2 lines of the field are brought onto the screen and the rest is hidden until the next field is moved up. I am confused because the focusRect.height variable is the correct height of the field. Is this a bug or something I am missing in my code?
Code:
class TextRichTextField extends RichTextField {
			
			public TextRichTextField(String text){
				super(text);
			}
			
			public TextRichTextField(String text, long style){
				super(text, style);
			}
			
			XYRect focusRect;
            protected void onFocus(int direction) {
                if ( focusRect == null ) {
                    focusRect = this.getExtent();
                }
                super.onFocus(direction);
                invalidate();
            }
            
            protected void unFocus() {
                super.onUnfocus();
                invalidate();
            }
            
            public boolean isSelectable() {
                return false;
            }
            
            public boolean isFocusable() {
                return true;
            }
            
            protected void drawFocus(Graphics g, boolean on) {
                if ( focusRect != null ) {
                	super.drawHighlightRegion(g, Field.HIGHLIGHT_FOCUS | Field.HIGHLIGHT_SELECT, on, 0, 0, focusRect.width, focusRect.height);
                	this.invalidate();
                	super.drawFocus(g, on);
                }
                else {
                    super.drawFocus(g, on);                    
                }
            }
            public void getFocusRect(XYRect rect) {
                if ( focusRect == null ) {
                    super.getFocusRect(rect);
                }
                else {
                    rect.x = 0;
                    rect.y = 0;
                    rect.width = focusRect.width;
                    rect.height = focusRect.height;
                }                 
            }            
            public int moveFocus(int amount, int status, int time) {
            	return amount;
            }
            
            public void paint(Graphics graphics) {
           	    graphics.setColor(Color.WHITE);
           	    super.paint(graphics);
           	  }
		}
Offline  
Old 07-22-2009, 12:43 PM   #2
ComputerWolf
Knows Where the Search Button Is
 
ComputerWolf's Avatar
 
Join Date: Jul 2009
Model: 8310
PIN: N/A
Carrier: AT&T
Posts: 19
Default

Sorry for posting again, but I didn't see any edit button. Turns out the change is happening in 4.6 and above. 4.3 and 4.5 both focus the field to be fully on the screen. It may just be something in the code that I am missing and is causing it to act differently on the newer OS's.
Offline  
Old 07-23-2009, 02:49 AM   #3
hippocamp software
Thumbs Must Hurt
 
Join Date: Feb 2009
Model: 9000
PIN: N/A
Carrier: T-Mobile
Posts: 67
Default

Use this method in the screen class, pass it your field:

Quote:
public void ensureRegionVisible(Field field,
int x,
int y,
int width,
int height)

Attempts to make your provided region visible.

Pass this method a field, and a region (extent), and this method attempts to scroll the screen to make as much of your region visible as possible.

If your region is smaller than the screen's visible extent, this method does as little work as possible to ensure the entire region appears on the screen.

If your region is larger than the screen's visible extent, this method produces the net effect of aligning the top left corner of your region with the top left corner of the screen's visible extent.
Offline  
Old 07-23-2009, 10:45 PM   #4
ComputerWolf
Knows Where the Search Button Is
 
ComputerWolf's Avatar
 
Join Date: Jul 2009
Model: 8310
PIN: N/A
Carrier: AT&T
Posts: 19
Default

Problem solved! If I extend LabelField as opposed to RichTextField all works as it should. Not that I understand why there's a difference, but it works.
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


New Siemens 6SL3120-1TE28-5AA3 6SL3 120-1TE28-5AA3 in Box Expedited Shipping picture

New Siemens 6SL3120-1TE28-5AA3 6SL3 120-1TE28-5AA3 in Box Expedited Shipping

$2289.00



Siemens 6SL3130-6AE21-0AB1 Smart Line Module 6SL3 130-6AE21-0AB1 Express Ship picture

Siemens 6SL3130-6AE21-0AB1 Smart Line Module 6SL3 130-6AE21-0AB1 Express Ship

$999.00



Siemens 6SL3210-1KE23-2AF1 6SL3210-1KE23-2AF1  1PC New In Box picture

Siemens 6SL3210-1KE23-2AF1 6SL3210-1KE23-2AF1 1PC New In Box

$1088.00



New Factory Sealed SIEMENS 6SL3210-1KE15-8UF2 6SL3 210-1KE15-8UF2 In Box picture

New Factory Sealed SIEMENS 6SL3210-1KE15-8UF2 6SL3 210-1KE15-8UF2 In Box

$850.20



New Siemens 6ES7151-3BA23-0AB0 Interface Module 6ES7 151-3BA23-0AB0 picture

New Siemens 6ES7151-3BA23-0AB0 Interface Module 6ES7 151-3BA23-0AB0

$323.00



SIEMENS 25-135-017-553 GRAY MCC Breaker Handle Switch Mechanism QTY picture

SIEMENS 25-135-017-553 GRAY MCC Breaker Handle Switch Mechanism QTY

$339.99







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