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
Contributor
sanghamitra_83
Posts: 17
Registered: ‎08-06-2012
My Device: Curve 9320

Scrolling Issue in Chat window

Hi,

 

I am desiging a chat window. The EditField is placed at the buttom of my window in a separate verticalFieldManager. The chat data is being added to another verticalFieldManager on top. But the chat data by default scrolls down. Means, to read the latest chat user has to scroll down, I want to make the top Manager scroll up so that the latest chat is always visible and the older data scrolls up.

 

How can I do that. Please help.

 

Regards,

Sanghamitra

Super Contributor
pp
Posts: 278
Registered: ‎11-04-2010
My Device: 4.5 and above

Re: Scrolling Issue in Chat window

Hi,

You can set verticall scroll when that chat window is onFocus... something like this...

protected void onFocus(int direction) {
Manager manager;
int managerHeight = -1;
int managerScroll = -1;
int currentTop = -1;

manager = this.getManager();
if(manager != null) {
managerHeight = manager.getPreferredHeight();
managerScroll = manager.getVerticalScroll();
currentTop = this.getTop();

if(direction == 1 && currentTop > (managerScroll + managerHeight)) {
manager.setVerticalScroll(currentTop);
} else if(direction == -1 && currentTop < managerScroll) {
manager.setVerticalScroll(currentTop);
}
}
super.onFocus(direction);
}

Regards,
pp