0
votes

I want to create a list of switches (or custom controls that handle horizontal pointer movements). That is easily done by putting those components in a Container using BoxLayout.y as LayoutManager. But because the components (the horizontally movable Switch or custom components) take a lot of room in the list it is very difficult to scroll the list. This is because all the pointer events are handled by the nested components and none get through to the surrounding Container - the one with the BoxLayout.y.

The natural thing I tried to do was to call the respective pointer...-Methods of the parent Container - which turned out to be a stupid idea - it led to a StackOverflowError.

What I really would like to do was handle the pointer events in both the child and the parent Components for a certain threshold distance on order to determine whether the user wants to scroll horizontally or vertically.

I noticed that with nested BoxLayout.x-Containers nested in a BoxLayout.y-Container this works out of the box. But I haven't been able to grasp how to achieve that with a custom control - and it does not work the the CN1-Switch-Components either.

The question is: How do do this in a reasonable manner? Is it even possible? Or would that require gesture detection which is not (yet) part of Codename One?

1

1 Answers

0
votes

This is the default behavior of Codename One. Scrolling takes over and there are biases based on the X/Y axis you use. All of that is built in. As I recall you changed a lot of default behaviors in Codename One, I suggest trying a clean project and seeing how it works e.g. with something like this: https://www.codenameone.com/blog/button-lists.html