Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign updefault cancelTouchFocusChild() to protected #2355
Conversation
To be able to extend Scrollpane and have control about those methods, see http://www.badlogicgames.com/forum/viewtopic.php?f=11&t=16416 Not sure what has to be changed on the gwt backend
|
Does setting |
|
No, as I need some informationa about the Scrollpane to block it or not. |
|
Before I merge, I'd like to understand why you need it. Why block it sometimes? Maybe disable flick scrolling? |
|
Dont think it would do the job: |
|
How about |
|
Yes, I am using that for disabling scrolling, but that doesnt have any effect on releasing the focus of the childs. the draglistener is attached to each widgetGround inside the scrollpane. |
|
Maybe you can show a simple executable example of the problem? I'm guessing you can stop the drag event so it never reaches the scroll pane if the DragAndDrop is handling it. |
|
Project :) |
|
Next time please use post a single class that shows the issue. Here's code to do what you want, I don't think ScrollPane needs any changes. import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.backends.lwjgl.LwjglApplication;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.ui.Image;
import com.badlogic.gdx.scenes.scene2d.ui.ScrollPane;
import com.badlogic.gdx.scenes.scene2d.ui.Table;
import com.badlogic.gdx.scenes.scene2d.utils.DragListener;
public class TestGui extends Table {
private Table contentTable;
/** if the user drags in x -direction drag should be called until the user, not the scrollpane calls the touchUp <br>
* I am not looking for a hacky solution I need one class to do this as this feature is used very often <br>
* @param stage */
public TestGui (final Stage stage) {
stage.clear();
this.setSize(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
this.defaults().top();
contentTable = new Table();
Image firstL = new Image(new Texture("badlogic.jpg"));
Image secondL = new Image(new Texture("badlogic.jpg"));
contentTable.add(firstL).expandX().fillX();
contentTable.row();
contentTable.add(secondL).expandX().fillX();
contentTable.setSize(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
final ScrollPane sp = new ScrollPane(contentTable);
add(sp).expandX().fillX().height(Gdx.graphics.getHeight() / 2);
sp.setScrollingDisabled(true, false);
stage.addActor(this);
DragListener dragListener = new DragListener() {
private boolean ignoreHorizontalDrag;
public void dragStart (InputEvent event, float x, float y, int pointer) {
System.out.println(Math.abs(getTouchDownY() - y));
ignoreHorizontalDrag = Math.abs(getTouchDownY() - y) > getTapSquareSize();
if (ignoreHorizontalDrag) {
System.out.println("Drag started vertically, ignore DragListener drag.");
} else {
System.out.println("Drag started horizontally, ignore ScrollPane drag.");
sp.cancel();
}
}
public void drag (InputEvent event, float x, float y, int pointer) {
if (ignoreHorizontalDrag) return;
System.out.println("drag first " + x);
}
};
dragListener.setTapSquareSize(19); // Can be anything less than the ScrollPane's default of 20.
firstL.addListener(dragListener);
}
public static void main (String[] arg) {
new LwjglApplication(new Test());
}
} |
|
I will do it next time :) |
Phibedy commentedSep 20, 2014
To be able to extend Scrollpane and have control about those methods,
see http://www.badlogicgames.com/forum/viewtopic.php?f=11&t=16416
Not sure what has to be changed on the gwt backend