Adding SpanButton to Swipeable container Issue

23 views
Skip to first unread message

Mark Bolduc

unread,
Oct 26, 2019, 4:09:54 PM10/26/19
to CodenameOne Discussions
If you are experiencing an issue please mention the full platform your issue applies to:
IDE: NetBeans/Eclipse/IDEA NetBeans 11.0
Desktop OS Windows 10 Pro
Simulator Latest
Device PC, IOS, Android

I have 2 SpanButton components in a Swipeable container, however the swipe action is rarley caught.
However if I substitute SpanButton with Button, the operation behaves as expected.

Here is a repeatable test case.

            Form hi = new Form("MpiImagesSwipeableContainer", new BoxLayout(BoxLayout.Y_AXIS));
            Container ctr = new Container(new BoxLayout(BoxLayout.Y_AXIS));
            ctr.setScrollableY(true);
            for (int a = 0; a < 5; a++) {
                Container TestCont = new Container(new com.codename1.ui.table.TableLayout(1, 2), "SchedEditContainerThickBorder");
                TextArea SrvJobText = new TextArea("A-" + (a + 1) + " Service");
                SrvJobText.setHint("Touch To Open Service Jobs Menu");
                SrvJobText.setEditable(true);
                TextArea SrvJobText1 = new TextArea("B-" + (a + 1) + " Service");
                SrvJobText1.setHint("Touch To Open Service Jobs Menu");
                SrvJobText1.setEditable(true);
                buildConstrantsGeneric(TestCont, SrvJobText, 0, 0, 50);
                buildConstrantsGeneric(TestCont, SrvJobText1, 0, 1, 50);
                SrvJobText.setUIID("MpServiceField");
                SpanButton menuButton = new SpanButton("Delete");
                menuButton.setName("Button");
                menuButton.setUIID("A3VacTableTotalHrsCellRed");
                SpanButton editButton = new SpanButton("Edit");
                editButton.setName("Button");
                editButton.setUIID("A3VacTableTotalHrsCell");
                SwipeableContainer MpiImagesSwipeableContainer = new SwipeableContainer(menuButton, editButton, TestCont);
                MpiImagesSwipeableContainer.setUIID("SwipeableContainerRoundedBorder");
                menuButton.addActionListener((evt) -> {
                    MpiImagesSwipeableContainer.close();
                });
                menuButton.addFocusListener(new FocusListener() {
                    @Override
                    public void focusGained(Component cmp) {
                        System.out.println("menuButton: focusGained");
                    }
                    @Override
                    public void focusLost(Component cmp) {
                        System.out.println("menuButton: focusLost");
                        MpiImagesSwipeableContainer.close();
                    }
                });
                editButton.addActionListener((evt) -> {
                    MpiImagesSwipeableContainer.close();
                });
                ctr.add(MpiImagesSwipeableContainer);
                MpiImagesSwipeableContainer.addSwipeOpenListener(e -> {
                    menuButton.requestFocus();
                });
            }
            hi.add(ctr);
            hi.show();

Regards

Shai Almog

unread,
Oct 26, 2019, 11:06:37 PM10/26/19
to CodenameOne Discussions
Can you file an issue on that?
Why are you using a span button instead of Button here?
Essentially lead components are a bit trickier in some edge cases such as this as their event propagation is a bit more nuanced.

Mark Bolduc

unread,
Oct 27, 2019, 10:29:07 AM10/27/19
to CodenameOne Discussions
SpanButton will provide Text Wrapping.

Any alternative Button options that would allow this?

Regards

Shai Almog

unread,
Oct 27, 2019, 11:01:21 PM10/27/19
to CodenameOne Discussions
Yes but under a swipeable container for words as short as "edit"?
There's no decent alternative that will work which is why I asked for an issue to track this.

Mark Bolduc

unread,
Nov 2, 2019, 4:59:16 PM11/2/19
to CodenameOne Discussions
My Customers will be using several words that span.

Regards
Reply all
Reply to author
Forward
0 new messages