'How to have a longPress Event on a CheckBox in Codenameone?

i need to implement a long press event on a checkbox in codenameone. On normal buttons i use the longPointerPress method and a boolean to control if the short- or longpress event happens. With the checkboxes i cannot find that option, it only toggles between checked/unchecked.

How is it possible to use a long press on a checkbox?

Thanks for your help!



Solution 1:[1]

I'm not familiar with codenameone, but in Android you can just use setOnLongClickListener since every View has that function.

Solution 2:[2]

longPress is a callback. You don't invoke it, you override it and it triggers when a longpress occurs. So Codename One invokes it internally. See the answer here: https://stackoverflow.com/a/54063388/756809

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 zen_of_kermit
Solution 2 Shai Almog