Codenameone 如何对自定义组件中的拖动结束作出反应

Codenameone 如何对自定义组件中的拖动结束作出反应,codenameone,Codenameone,我注意到,不能保证在调用其pointerPressed方法之后调用components pointerReleased方法 对于Conponent派生(处理指针事件的派生),在所有情况下,获得指针释放事件通知的推荐方法是什么 假设我的自定义组件应该是绿色的,点击时变为红色。当指针不再按下时,我如何保证它再次变为绿色 新示例-组件派生,isStickyDrag()返回true-记录指针事件-当按下组件并垂直拖动时,周围的容器实例滚动-无指针删除,然后: Form hi = new For

我注意到,不能保证在调用其pointerPressed方法之后调用components pointerReleased方法

对于Conponent派生(处理指针事件的派生),在所有情况下,获得指针释放事件通知的推荐方法是什么

假设我的自定义组件应该是绿色的,点击时变为红色。当指针不再按下时,我如何保证它再次变为绿色


新示例-组件派生,isStickyDrag()返回true-记录指针事件-当按下组件并垂直拖动时,周围的容器实例滚动-无指针删除,然后:

    Form hi = new Form("Hi World", BoxLayout.y());
    hi.setScrollableY(true);
    Component component = new Component() {
        @Override
        protected Dimension calcPreferredSize() {
            return new Dimension(120, 120);
        }
        @Override
        public void paint(Graphics aGraphics) {
            aGraphics.setColor(0x000000);
            aGraphics.drawRoundRect(getX(), getY(), getWidth() - 1, getHeight() - 1, 20, 20);
        }
        @Override
        protected boolean isStickyDrag() {
            return true;
        }
        protected int getDragRegionStatus(int x, int y) {
            return Component.DRAG_REGION_IMMEDIATELY_DRAG_XY;
        };
        @Override
        public void pointerPressed(int x, int y) {
            super.pointerPressed(x, y);
            Log.p("pointerPressed(" + x + ", " + y + ")");
        }
        @Override
        public void pointerReleased(int x, int y) {
            super.pointerReleased(x, y);
            Log.p("pointerReleased(" + x + ", " + y + ")");
        }
    };
    hi.add(component);
    hi.show();

它应该覆盖isStickyDrag方法,如下所示:

protected boolean isStickyDrag() {
    return true;
}

它已经定义了它,在这种情况下,应该始终接收指针释放事件。

它应该覆盖isStickyDrag方法,如下所示:

protected boolean isStickyDrag() {
    return true;
}

它已经定义了它,在这种情况下,应该始终接收指针释放事件。

但它没有-请参阅带有组件派生的新示例和说明。即使isStickyDrag返回true,您也可以进入不调用pointerReleased的状态。这可能是一个bug,但我没有查看它,但它没有-请参阅带有组件派生和描述的新示例。即使isStickyDrag返回true,您也可以进入不调用pointerReleased的状态。这可能是一个bug,但我还没有研究它