2
votes

I actually asked this before but have not received a satisfactory answer - so I will try to formulate the question differently.

When a BoxLayout.X Container is nested in a BoxLayout.Y Container one can scroll both ways and after a certain threshold it sticks to vertical or horizontal movement.

What I want is the same behaviour with a Component where the Component derivative is nested in a Container using BoxLayout.Y. Both the Component derivative and the Container it is nested in should handle pointer movements - the Component the horizontal movements and the Container the vertical pointer movements - until the pointer has moved a certain distance and then it should lock to either vertical movement or horizontal movement, just like it already sort of works with nested Container components.

This would greatly enhance the user experience because out of the box with Codename One dragging for example a switch vertically does not work because it swallows all the pointer events, not only the horizontal movements but all of them. Now - the desired behaviour described above appears hard to achieve because one cannot delegate pointer movement events to the parent Container.

Any ideas of how that could be done?

2

2 Answers

0
votes

This is implemented in several layers. One of them is:

protected int getDragRegionStatus(int x, int y);

A component can return a bias to a specific axis by overriding this method. E.g. by returning DRAG_REGION_LIKELY_DRAG_X.

The second bit is through the stickyDrag member of form which biases drag behavior to the source component.

0
votes

Apparently the default scrolling functionality works when the Component pointer* methods are either not overridden or if the overriding methods call the super methods.

In the Codename One Switch component the vertical scrolling of a parent Container doesn’t work because it just overrides the pointer* methods of Component. See the corresponding bug in issue 2645