Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Developer
juanmab
Posts: 94
Registered: ‎07-08-2011
My Device: Many
Accepted Solution

Scroll happening but Vertical Field Manager Not Moving

[ Edited ]

Hi guys.

Here's the deal.

I have a horizontal field manager and a vertical field manager

Inside the vfm I add many custom vertical field manager with a label field and a custom rich text field. 

 

The app layout is something like this (whit it's style):

MainScreen

---------HFM  (Manager.USE_ALL_WIDTH)

---------VFM (Manager.VERTICAL_SCROLL | Manager.VERTICAL_SCROLLBAR | Manager.FOCUSABLE);

------------------CVFM (FIELD_HCENTER | FOCUSABLE)

---------------------------LF (LabelField.ELLIPSIS | LabelField.USE_ALL_WIDTH)

---------------------------CRTF (RichTextField.USE_ALL_WIDTH | RichTextField.NON_FOCUSABLE)

------------------CVFM

---------------------------LF

---------------------------CRTF

------------------CVFM

---------------------------LF

---------------------------CRTF 

 

And many more CVFM

 

I want to scroll down whit the arrows between the CVFM and Im able to do so but..... (yeah, always a but)

As I go down the list focus element goes out of the screen. 

 

If I put the CRTF as FOCUSABLE I'm getting it to work but I have to press the arrow one time for each text line. 

 

If source code is required just ask.  

 

Thanks.


Feel free to press the like button on the right side to thank the user that helped you.
Please mark posts as solved if you found a solution.

Juanma 

@juanmab

Please use plain text.
Developer
peter_strange
Posts: 19,607
Registered: ‎07-14-2008
My Device: Not Specified

Re: Scroll happening but Vertical Field Manager Not Moving

I don't understand this:

"the list focus element "

 

What is the list focus element?

 

In this case however you might find that changing your CRTF to be non focusable, and adding a NullField after then provides the focus movement you want.  Set like this, focus will move up and down by one CVFM at a time.

Please use plain text.
Developer
arkadyz
Posts: 2,268
Registered: ‎07-08-2009
My Device: various

Re: Scroll happening but Vertical Field Manager Not Moving

I remember a bug like that reported here. It was a ListField and MainScreen's status with a button. For some reason, ListField did not scroll up when its focus hid behind the status. Even though you have something different, that might very well be another manifestation of it. Try making your MainScreen(NO_VERTICAL_SCROLL) and adding a scrolling VFM with limited height, to which you'd add a ListField. See if it helps.

 

Anyway - the problem was not on all models and OS versions, some older phones did not have it (was only 5.0 and 6.0 affected? I don't remember). Try building for, say, 4.6 and running on a 4.6 phone (if you can find one).

----------------------------------------------------------
please click 'Accept Solution' on posts that provide the solution to the question you've posted. Don't say "Thanks", press 'Like' button instead!
Please use plain text.
Developer
juanmab
Posts: 94
Registered: ‎07-08-2011
My Device: Many

Re: Scroll happening but Vertical Field Manager Not Moving

Thanks guys,

@arkadyz, still happening in 4.6.1

 

I'll try what @peter said

 

Here's some screenshots

 

I got the feeds and I focus on first element

 

Scrolling down

 

Almost loosing sight of focused element

 

Then It's gone out of the screen 


Feel free to press the like button on the right side to thank the user that helped you.
Please mark posts as solved if you found a solution.

Juanma 

@juanmab

Please use plain text.
Developer
juanmab
Posts: 94
Registered: ‎07-08-2011
My Device: Many

Re: Scroll happening but Vertical Field Manager Not Moving

@peter

The nullField was a good idea, it almost did it.

 

As I have to add the nullField on top, middle or bottom of mi CVFM only works on an specific scrolling.

For example:

If I add it at the bottom, it's work fine while scrolling down but you don't see the CVFM on screen when scrolling up

The same when I put it on top. Works fine while scrolling up but not when scrolling down.

When added in the middle well. Half of the CVFM is shown when going up or down.

 

Gonna try adding another manager to get focus between my VFM and the CVFM and see what happens.

Maybe is this bug @arkadyz, mentioned or something similar.

 

I just don't get why the CVFM is highlighted in color (that's happens when it get the focus) but the scroll is not working....


Feel free to press the like button on the right side to thank the user that helped you.
Please mark posts as solved if you found a solution.

Juanma 

@juanmab

Please use plain text.
Developer
juanmab
Posts: 94
Registered: ‎07-08-2011
My Device: Many

Re: Scroll happening but Vertical Field Manager Not Moving

Well....

The good and the bad new

Adding another manager didn't solved it

I figured out that the problem should be in the CVFM class

The manager is getting the focus as it is being paint but I still do not know why it's not staying on screen

The code of the CVFM

 

 

public class CustomRssVerticalManager extends VerticalFieldManager{	

	private boolean _active; 
	
	private int bgNormalColor = Color.WHITE;
	private int bgFocusColor = Color.PURPLE; 
	private int bgActiveColor = Color.RED;
	private int fontNormalColor = Color.BLACK;
	
	private LabelField lfTitle;
	private CustomMultiLineTextField lfDescription;
	
	private Font fontTitleN = Font.getDefault().derive(Font.BOLD, 6, Ui.UNITS_pt);
	private Font fontTitleA = Font.getDefault().derive(Font.BOLD, 7, Ui.UNITS_pt);
	private Font fontTitleF = Font.getDefault().derive(Font.BOLD, 7, Ui.UNITS_pt);
	
	private Font fontDescriptionN = Font.getDefault().derive(Font.PLAIN, 5, Ui.UNITS_pt);
	private Font fontDescriptionA = Font.getDefault().derive(Font.PLAIN, 6, Ui.UNITS_pt);
	private Font fontDescriptionF = Font.getDefault().derive(Font.PLAIN, 6, Ui.UNITS_pt);	
	
	private RssItem rssItem;
	
	public CustomRssVerticalManager(RssItem rssItem, long style) {
		super(style | FOCUSABLE);
		
		this.rssItem = rssItem;	
		
		lfTitle = new LabelField(this.rssItem.getTitle(), LabelField.ELLIPSIS | LabelField.USE_ALL_WIDTH | LabelField.NON_FOCUSABLE);
		lfTitle.setFont(getFontTitle());
		lfDescription = new CustomMultiLineTextField(this.rssItem.getDescription(), 3, RichTextField.USE_ALL_WIDTH | RichTextField.NON_FOCUSABLE, getFontDescription());
		lfDescription.setFont(getFontDescription());
		
		this.setBackground(BackgroundFactory.createSolidBackground(bgNormalColor));
		
		this.add(lfTitle);		
		this.add(lfDescription);
		
		this.setMargin(new XYEdges(3, 3, 3, 3));
	}	
	
	protected void sublayout(int width, int height){		
		super.sublayout(width, height);
	}
	
	public boolean isFocusable() {
		return true;
	}	
	
	private Font getFontTitle() {
		if( _active ) {
			return fontTitleA;
		} else if (isFocus()) {
			return fontTitleF;
		} else {
			return fontTitleN;
		}
	}
	
	private int getBackgroundColor() {
		if( _active ) {
			return bgActiveColor;
		} else if (isFocus()) {
			return bgFocusColor;
		} else {
			return bgNormalColor;
		}
	}
	
	private Font getFontDescription() {
		if( _active ) {
			return fontDescriptionA;
		} else if (isFocus()) {
			return fontDescriptionF;
		} else {
			return fontDescriptionN;
		}
	}		
	
	protected void subpaint(Graphics g) {
		g.setColor(getBackgroundColor());
		g.fillRect(0, 0, getWidth(), getHeight());
		g.setColor(fontNormalColor);
		
		super.subpaint(g);
	}
	
	protected void onFocus(int direction) {
		super.onFocus(direction);
		lfDescription.setFont(getFontDescription());
		lfTitle.setFont(getFontTitle());
		invalidate();
	}
	
	protected void onUnfocus() {
		super.onUnfocus();
		lfDescription.setFont(getFontDescription());
		lfTitle.setFont(getFontTitle());
		invalidate();
	}
	
	protected boolean navigationClick(int status, int time) {
		_active = true;
		invalidate();
		return super.navigationClick(status, time);
	}

	protected boolean navigationUnclick(int status, int time) {
		_active = false;
		invalidate();
		clickButton();
		return true;
	}
	
	protected boolean touchEvent(TouchEvent message) {
		boolean isOutOfBounds = touchEventOutOfBounds(message);
		
		switch (message.getEvent()) {
		case TouchEvent.DOWN:
			if (!isOutOfBounds) {
				if (!_active) {
					_active = true;
					invalidate();
				}
				setFocus();
				return true;
			}
			return false;
		case TouchEvent.UNCLICK:
			if (_active) {
				_active = false;
				invalidate();
			}
			if (!isOutOfBounds) {
				clickButton();
				return true;
			}
		case TouchEvent.UP:
			if (_active) {
				_active = false;
				invalidate();
			}
		default:
			return false;
		}
	}
	
	private boolean touchEventOutOfBounds(TouchEvent message) {
		int x = message.getX(1);
		int y = message.getY(1);
		return (x < 0 || y < 0 || x > getWidth() || y > getHeight());
	}
	
	private void clickButton(){
		Browser.getDefaultSession().displayPage(this.rssItem.getLink());		
	}
}

 


Feel free to press the like button on the right side to thank the user that helped you.
Please mark posts as solved if you found a solution.

Juanma 

@juanmab

Please use plain text.
Developer
juanmab
Posts: 94
Registered: ‎07-08-2011
My Device: Many

Re: Scroll happening but Vertical Field Manager Not Moving

[ Edited ]

As I couldn't hack it I got a back up version from a couple days ago where it worked fine.

 

So I copied styles, layouts, sublayouts, paints, subpaints and everything that seemed to be related.

No luck.

 

Started getting really <removed> off so I got the old version running instead of fixid the lasted and I still have the problem!!

 

So I'm started to think about the emulator.

 

Any ideas? Reseting or something like that?

 

EDIT: Content Removed. Please avoid bypassing the word filter.


Feel free to press the like button on the right side to thank the user that helped you.
Please mark posts as solved if you found a solution.

Juanma 

@juanmab

Please use plain text.
Developer
juanmab
Posts: 94
Registered: ‎07-08-2011
My Device: Many

Re: Scroll happening but Vertical Field Manager Not Moving

I guess the only solution to this is using a nullfield as I've been previously told

Looks like a common problem.

http://supportforums.blackberry.com/t5/Java-Development/My-scrollable-manager-is-not-scrolling/ta-p/...

 

@jakoby4204 I didn't spected that word written like that to be edited. I'm sorry won't happen again.


Feel free to press the like button on the right side to thank the user that helped you.
Please mark posts as solved if you found a solution.

Juanma 

@juanmab

Please use plain text.
Developer
juanmab
Posts: 94
Registered: ‎07-08-2011
My Device: Many

Re: Scroll happening but Vertical Field Manager Not Moving

The other solution to this is using a LisfField.

Had to rewrite a couple of things and forget about my Custom Vertical Manager.

 

This bug really is a pain....


Feel free to press the like button on the right side to thank the user that helped you.
Please mark posts as solved if you found a solution.

Juanma 

@juanmab

Please use plain text.
Contributor
urodba
Posts: 12
Registered: ‎08-16-2011
My Device: 9300

Re: Scroll happening but Vertical Field Manager Not Moving

[ Edited ]

A friend gave me the solution... you can put your manager into an horizontal manager and then you can just add an nullfield with a focusable behaviour but the trick is give the manager (you want to scroll) height to this new nullfield i think that manager.getVirtualHeight do that trick. 

Please use plain text.