Fire a button by message handler

Hi guys,

I have a view in perspective with a drop down box and a button. A barcode scanner will be connected to this view, so the user can just scan a barcode to the drop down box, or pick an option there.
The scanner sends a “enter key” command after scanning the barcode.
I have a script in the action onKeyPress in my drop down that calls a message handler to fire the button, where I have my script at onClick event.

*messageType = 'PressEnter'*
  • system.perspective.sendMessage(messageType)*

I need to create the message handler ‘PressEnter’ in my button, but I don’t know how to fire the onClick action into the message.
Any ideas about what code I can use in the message handler?

Thank you.

You generally cannot do that (with caveats in Vision). The supported solution is to move the code in the button’s action script to a function in a project script module, from where it can be called by both the button and the message handler.

If you goal is to just scan a barcode into a field, then you approach is more complicated than in needs to be. Use the barcode input component which will bring in the barcode scanner data for you, then when that data is present you can update the dropdown value.

Thank you guys. Actually, my view is working with the scanner. Since the focus is on the dropdown, I can just scan a barcode and the data is shown there. Than, I need to press the button to process my code.
Like the handheld scanners, I want just scan the barcode and the scanner would trigger my button.