ScrollPanel uses setAsContainerOnly(), mouse events not possible

I’ve got a control that extends ScrollPanel (the XHTML renderer actually). I just noticed a little tweak I made to the tonegod source for this (totally forgot about it before), and that is the commenting out of “setAsContainerOnly” in ScrollPanel. Without this (or the hack below), it doesn’t seem possible to get mouse events on the ScrollPanel itself.

Is this expected? Should containers still get events? Maybe there needs to be a setAsNonContainer() or something as well (I am using a hack with this function for now).

[java]
// Turn this ScrollPanel back into a rendered control so it gets mouse events
attachChildAt(getGeometry(), 0);
[/java]

@rockfire said: I've got a control that extends ScrollPanel (the XHTML renderer actually). I just noticed a little tweak I made to the tonegod source for this (totally forgot about it before), and that is the commenting out of "setAsContainerOnly" in ScrollPanel. Without this (or the hack below), it doesn't seem possible to get mouse events on the ScrollPanel itself.

Is this expected? Should containers still get events? Maybe there needs to be a setAsNonContainer() or something as well (I am using a hack with this function for now).

[java]
// Turn this ScrollPanel back into a rendered control so it gets mouse events
attachChildAt(getGeometry(), 0);
[/java]

This should only effect the container itself. Since it has no geometry, setAsContainerOnly’s ignore mouse is a safety measure to ensure the screen class doesn’t try and resolve effectParent or effectAbsoluteParent flags that shouldn’t be, but might be, set by the user.

When you say events aren’t processed, do you mean that the container isn’t receiving events or that child elements aren’t as well?

Ah I think I get you.

These events are on the container itself. So I have TGGXHTMLRenderer that ultimately extends ScrollPanel. I needed to get at mouse events on the container as a whole, so I added …

[java]
innerBounds.setIgnoreMouse(true);
innerBounds.setIgnoreMouseButtons(true);
scrollableArea.setIgnoreMouse(true);
setIgnoreMouse(false);
[/java]

… in my constructor for this class, and the following pile of overrides …

[java]
@Override
public void onMouseMove(MouseMotionEvent e) {
Vector2f p = convertPoint(e);
mouseHover§;
mouseCursor§;
}

@Override
public void onMouseLeftPressed(MouseButtonEvent evt) {
}

@Override
public void onMouseLeftReleased(MouseButtonEvent evt) {
    String uri = findLink(convertPoint(evt.getX(), evt.getY()));
    if (uri != null) {
        linkClicked(uri);
    }
}

@Override
public void onMouseRightPressed(MouseButtonEvent evt) {
}

@Override
public void onMouseRightReleased(MouseButtonEvent evt) {
}

@Override
public void onMouseWheelPressed(MouseButtonEvent evt) {
    // Pass mouse wheel events on to the scroll pane
    ((MouseWheelListener) getScrollBounds()).onMouseWheelPressed(evt);
}

@Override
public void onMouseWheelReleased(MouseButtonEvent evt) {
    // Pass mouse wheel events on to the scroll pane
    ((MouseWheelListener) getScrollBounds()).onMouseWheelReleased(evt);
}

@Override
public void onMouseWheelUp(MouseMotionEvent evt) {
    // Pass mouse wheel events on to the scroll pane
    ((MouseWheelListener) getScrollBounds()).onMouseWheelUp(evt);
}

@Override
public void onMouseWheelDown(MouseMotionEvent evt) {
    // Pass mouse wheel events on to the scroll pane
    ((MouseWheelListener) getScrollBounds()).onMouseWheelDown(evt);
}

[/java]

When ScrollPanel is set as a container I don’t get any events at all. In case you were wondering why I am passing on mouse wheel events, there was a good reason for this, but I can’t remember right now what it was :slight_smile:

EDIT: I should say I actually had something similar when converting Table to ScrollPanel. In that case though, I ended up getting the mouse events at the TableRow level, which in that case worked out OK. I could do the same here I guess, but it would mean adding mouse handling to a number of classes that otherwise wouldn’t need it.

EDIT 2: Oh, heh, I addded listeners as well …

[java]
implements MouseMovementListener, MouseButtonListener, MouseWheelListener
[/java]