darryncampbell / react-native-datawedge-intents

React Native interface for Zebra's DataWedge Intent API
MIT License
43 stars 46 forks source link

get scan button key down event #2

Closed FrancescaBarbazeni closed 3 years ago

FrancescaBarbazeni commented 6 years ago

Hello Darry,

I was wondering how to modify your module in order to obtain the time in which the scan button is pressed. This because I need to know how much time has passed between scanning start and scanning result (barcode data). Could I override some kind of Class to retrieve starting time?

Thank you, Francesca

darryncampbell commented 6 years ago

Hi, do you mean the physical trigger key or do you have a soft button on your UI that invokes DataWedgeIntents.ACTION_SOFTSCANTRIGGER? For the physical trigger, you might be able to use something like https://github.com/kevinejohn/react-native-keyevent to detect it. If the trigger is not detected then you may need to remap it using something like the technique described at http://www.darryncampbell.co.uk/2017/07/07/controlling-datawedge-via-key-presses/.

FrancescaBarbazeni commented 6 years ago

Thank you Darry,

but I'd like to do that in your module, not in the react component. Something like:

@Override
    public void onKeyDown(int keyCode, KeyEvent event) {
        if( keyCode === KeyEvent.KEYCODE_BUTTON_L1) {
                SCAN_START = Calendar.getInstance().getTimeInMillis();
        }
    }

But obviously it doesn't work.

Thank you so much

darryncampbell commented 6 years ago

I'm not sure why it doesn't work, maybe take a look at that other plugin I referenced as they are doing something in onKeyDown. Feel free to modify my module, it is released under MIT so there should be no licensing concerns. Edit: Just realised I had not labelled it as MIT - I will do that now...