timePicker Capture Cancel Click

43 views
Skip to first unread message

shop.servic...@gmail.com

unread,
Aug 31, 2017, 10:37:32 PM8/31/17
to CodenameOne Discussions
If you are experiencing an issue please mention the full platform your issue applies to:
IDE: NetBeans/Eclipse/IDEA NetBeans 8.2
Desktop OS Windows 10
Simulator 7.3
Device Simulator Android, IOS

How do I catch the Cancel event?
                            Picker timePicker = new Picker();
                            timePicker.setUIID("TableCell");
                            timePicker.setType(Display.PICKER_TYPE_STRINGS);
                            String[] st = new String[23];
                            for (int a = 0; a < 23; a++) {
                                st[a] = String.valueOf(a + 1);
                            }
                            timePicker.setStrings(st);
                            timePicker.setSelectedString((String) value);
//                            System.out.println("timePicker.getSelectedString() = ["+timePicker.getSelectedString()+"]");
                            timePicker.addActionListener((e)
                                    -> setTableRowFromPtoHoursPerDay(row, column, timePicker.getSelectedString())
                            );
                            return timePicker;

    private void setTableRowFromPtoHoursPerDay(int row, int column, Picker timePicker) {
        System.out.println("setTableRowFromPtoHoursPerDay: row = " +
                row + " column = " + column + " text = [" + timePicker.getTime()+"]");
    }

timePicker  always returns Selected String.

I need to know that the Cancel Button was clicked.

Regards


Shai Almog

unread,
Aug 31, 2017, 11:46:16 PM8/31/17
to CodenameOne Discussions, shop.servic...@gmail.com
Hi,
why do you need that?
This isn't necessarily as simple as cancel might not exist in the native UX.

shop.servic...@gmail.com

unread,
Sep 1, 2017, 10:11:46 AM9/1/17
to CodenameOne Discussions, shop.servic...@gmail.com
I'm using the Cancel to nullify the date
This happened to be a Vacation request table cell  where a user selects a date (Which Approves this request)
Hitting Cancel deletes the Entry (Which Says This Row is not approved)

Is there another calendar class I can use?

Regards

Shai Almog

unread,
Sep 2, 2017, 2:03:45 AM9/2/17
to CodenameOne Discussions, shop.servic...@gmail.com
There is Calendar which now supports selecting multiple days.

shop.servic...@gmail.com

unread,
Sep 2, 2017, 8:59:26 AM9/2/17
to CodenameOne Discussions, shop.servic...@gmail.com
Is that the CN1Calendar.cn1lib?
If so can you please point me to a working code example?

Regards.


On Saturday, September 2, 2017 at 2:03:45 AM UTC-4, Shai Almog wrote:

Shai Almog

unread,
Sep 3, 2017, 12:16:18 AM9/3/17
to CodenameOne Discussions, shop.servic...@gmail.com
No it's the Calendar class in the UI package. If there isn't a sample there we don't have one. It's a pretty old class.

shop.servic...@gmail.com

unread,
Sep 3, 2017, 9:49:37 AM9/3/17
to CodenameOne Discussions, shop.servic...@gmail.com
Ok, Any other thoughts on how I can capture the Cancel button on the Picker Class?

Shai Almog

unread,
Sep 4, 2017, 12:16:45 AM9/4/17
to CodenameOne Discussions, shop.servic...@gmail.com
Maybe using the low level picker API calls in Display will help your use case. Notice they will only work on the device.
Reply all
Reply to author
Forward
0 new messages