Hi,
I am facing issue with scrolling while selecting tree item in tree.
While tree is bigger then it's root panel, scroll is coming. If I click on any item, it will just adjust scroll first then second time I have to do same thing. It will do selection as expected. But The problem with I don't want twice click / selection. It should do in first attempt only.
As I goggled then find similar this problem like http://code.google.com/p/google-web-toolkit/issues/detail?id=1467
See below code, This is not my actual code implementation, It is sample example to find actual root cause.
public class TestGWTScroll implements EntryPoint {
@Override
public void onModuleLoad() {
ScrollPanel scrollPanel=new ScrollPanel();
scrollPanel.setHeight("200px");
scrollPanel.setWidth("100px");
CustomTree tree=new CustomTree();
tree.setTitle("tEST");
TreeItem item=tree.addItem(new HTML("Node1"));
item.addItem(new HTML("Child1 Item------------------------------------------->"));
item.addItem(new HTML("Child2"));
tree.addItem(new HTML("Node2"));
tree.addItem(new HTML("Node3"));
scrollPanel.add(tree);
RootPanel.get().add(scrollPanel);
}
class CustomTree extends Tree
{
@Override
public void onBrowserEvent(Event event) {
int eventType = DOM.eventGetType(event);
switch (eventType) {
case Event.ONCLICK:
case Event.ONKEYDOWN:
case Event.ONKEYPRESS:
case Event.ONKEYUP:
//case Event.ONMOUSEDOWN
return;
case Event.ONMOUSEDOWN:
if ((DOM.eventGetCurrentTarget(event) == getElement())
&& (event.getButton() == Event.BUTTON_LEFT)) {
//How to open selected tree item
}
default:
break;
}
super.onBrowserEvent(event);
}
}
}
As I found, The problem is with Dom event Event.ONMOUSEDOWN.
1) You find in code then I commented Case Event.ONMOUSEDOWN. if I return this event, it works perfect. Doesn't do scrolling first while mouse left key pressed. But tree open (+) operation stopped. Because Then open node event is handle inside this event.
2) So I decide to these events manually but how I don't know. As I found its all implementation methods are private.
Just example elementClicked is private not accessible. So this option is also not work for me.
case Event.ONMOUSEDOWN: {
// Currently, the way we're using image bundles causes extraneous events
// to be sunk on individual items' open/close images. This leads to an
// extra event reaching the Tree, which we will ignore here.
// Also, ignore middle and right clicks here.
if ((DOM.eventGetCurrentTarget(event) == getElement())
&& (event.getButton() == Event.BUTTON_LEFT)) {
elementClicked(DOM.eventGetTarget(event));
}
break;
}
How can I resolve this issue? From that tree open activity and scrolling issue work perfect for me.
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/groups/opt_out.
No comments:
Post a Comment