Long Press or Long Pointer Press Event

159 views
Skip to first unread message

mobo

unread,
Aug 29, 2014, 4:07:54 AM8/29/14
to codenameone...@googlegroups.com
What is the best way to handle or detect a long Press or Long Pointer Press Event triggered by a button component. Some examples will be nice. I tried to bind an Action Listener to a button and check the event if its a long event but it does not work. 

Thanks :)

Shai Almog

unread,
Aug 29, 2014, 10:16:21 AM8/29/14
to codenameone...@googlegroups.com, mobocr...@gmail.com
Derive the button and override the long press method. You won't get an action event for long press outside of list.

lin....@gmail.com

unread,
Mar 24, 2017, 10:35:20 PM3/24/17
to CodenameOne Discussions, mobocr...@gmail.com
Great, but some inconvenient.
Anyway, here is complete code.

class TemplateButton extends Button {
        public TemplateButton(String title){
            super(title);
        }
        @Override
        public void pointerReleased(int x, int y) {
            super.pointerReleased(x, y); //To change body of generated methods, choose Tools | Templates.
        }

        @Override
        public void pointerPressed(int x, int y) {
            super.pointerPressed(x, y); //To change body of generated methods, choose Tools | Templates.
        }

        @Override
        public void removeActionListener(ActionListener l) {
            super.removeActionListener(l); //To change body of generated methods, choose Tools | Templates.
        }

        @Override
        public void longPointerPress(int x, int y) {
            super.longPointerPress(x, y); //To change body of generated methods, choose Tools | Templates.
            //.............YOU CAN PUT YOUR CODE HERE............
Reply all
Reply to author
Forward
0 new messages