Detect press of "cancel" on a Codename One lightweight date picker - codenameone

On a Codename One lightweight date pickers, the user has four buttons in the top, like in the following screenshot.
I suppose the tapping of the second, third and fourth buttons are detected by the .addActionListener() (please correct me if I'm wrong)... but I need to detected also the tapping of the "Cancel" button. How can I run some code when the user taps "Cancel"?

We don't provide a way to detect cancel since we can't consistently detect it on native. As a workaround you can listen to the click on the picker button and unless you get a selection it would mean that the action was canceled.
Alternatively we can add a feature like this for the lightweight picker only. If you need that you can file an RFE on that.

I overcame this by comparing the newly selected picker value to the previously stored value. If it’s the same, I consider it a cancel.

Related

Don't show the Next or Done buttons in the Android VKB

How can I prevent the showing of the Next or Done buttons of the Android VKB in a Codename One app?
Currently, for my app, they are a mess: the next button of the VKB doesn't focus the next field, but the previous. After tons of trials, I didn't find a way to make them working correctly (but there are fine on iOS and on the Simulator). I also tried to override the Layout.overridesTabIndices(com.codename1.ui.Container) and Layout.getChildrenInTraversalOrder(com.codename1.ui.Container) methods in the Form, but nothing changed on Android.
I supposed two possible causes: the use of a Form inside a Form or, more probably, the fact that I replace all the TextFields and Pickers in the same Form (and other components). Maybe the fact that the inner Form is deeply changed results in a confusion for the Android mapping of the "next" button.
That's why my request: because I didn't find a way to make the "next" button useful, I'm asking how I can avoid that it's been shown.
Thank you
Nesting forms would probably mess with the focus traversal/tab order.
Normally you should be able to override public TabIterator getTabIterator(Component start) to return a blank iterator. I'd suggest doing the same for both the parent and child form to disable the "next" feature.

CodenameOne set indexing of fields for virtual keyboard

Using CodenameOne,
I have a Form that the user needs to fill in. All of the components, however, are actually Containers that represent custom functionality. As an example, I would have a TextField alongside a Button on a Container, and I would use that Container as a "Component". This allows me to create more advanced functionality by combining existing Components.
A good example of where this is necessary is that of a custom date entry field existing out of 3 TextFields or a combination of TextFields and ComboBoxes.
I have a "Field" that has functionality for that of a Contact Component.
This all serves as a single "Unit" in order to allow the user to choose a contact or fill in their own. Buttons open Dialog popups, etc.
My problems comes with when the user uses the Android keyboard. Should this Contact Object be the second "Field" and the user presses the 'Next' button on the Android keyboard, the App does not know what field to give focus.
Furthermore, If one of the fields are a ComboBox or a Button and the user presses next to reach that Component, the keyboard doesn't close, and instead removes the 'Next' button, replacing it with a return button or an emoticon selector.
Below is an example situation:
The user would press on the first field, the Keyboard shows up, and when the user presses next, the keyboard's Next button dissapears, as the immediate next field happens to be a Button or ComboBox.
Is there a way to change the focusing index, or omit certain fields form ever gaining focus in this way? I tried making the entire thing a Component but that doesnt allow me to combine other Components. Even if it is possible to make the parent Container a Component, how would I solve this particular issue?
The default behavior is to use the "next focus down" for this functionality so just use setNextFocusDown(nextTextField) on each one of the components. Notice that a ComboBox won't work as expected although you might want to change that to an AutoCompleteTextField which would.

Codename One - TextField appearance

I have a GUI built app and am trying to emulate the TextFIeld look of the Yahoo Mail page, where the underline of the TextField turns to blue when pressed.
I changed the "pressed" and "selected" state of the TextField UIID, but it only changes when I press it, but it doesn't stay that way and it turns back to grey.
Question:
Is there some kind of "toggle" function in TextFields as in CheckBoxes, so the new state stays that way?
Only selected state is used in text field (not pressed) and it should remain blue. It seems this is an issue with Codename One possibly a recent regression due to recent changes to text editing.
I've filed an issue on that here.

need way to close datebook when shown inline

I am using the stable version jQM DateBox with JQM 1.4.5 and jQuery 2.
I have a popup form that has a datebook widget on it. I use inline blind because the initial value is set for the date. But the user can click into the field, the datebook opens up the calendar and the user can pick a new date.
However, if the user opens up the datebook calendar, there's no way to close it without them picking a date. It would be nice if either clicking on the date field again closes the calendar (like a toggle) or there's an explicit close button that is shown when the calendar is shown.
Thanks.

how can I know how a popup menu was closed?

I have a WPF DatePicker, and like any datepicker, it has a built-in calendar that you can open by clicking on the small calendar icon.
this calendar is put in a popup menu, so that it behaves like one, i.e.: once it is opened, there are 2 ways to close it:
Validate you choice (click on a date with the mouse, hit "Enter" with a date highlighted, etc...)
cancel (hit "Echap", click outside the popup, etc...)
My problem is, I need to know which one was used, and I can't seem to find a way to do this.
Right now I listen to the "CalendarClosedEvent" but it doesn't tell me How the calendar was closed.
I also used the "PreviewKeyDownEvent" to trap the "Echap" key, which works well, except it does not cover the case when the user clicks outside the calendar to close it.
Is there a way to do this? if so, what is it?
(NB: I'd be happy with a generic answer about the popup menu object and not the calendar object in the datePicker)
For the DatePicker at least, you can set the SelectedDate to null (which is actually the default so, just leave it). Then the SelectedDateChanged fires any time the user clicks inside the control.
This is the only thing I could find to mark a difference. Hope it helps.

Resources