Adding a newly made method to a keyListener
Posted: Mon Apr 20, 2020 3:16 pm
Hi all,
I am currently making a function that creates keylisteners and callbacks on the fly, and adds them to an element. I've got it all working, except for one thing: I cannot get the addKeyListener method to recognize my new method correctly. The code to do so seems to be quite simple:
The first call creates a function called onKeyTxtTest for me. This works properly. It's the second line that doesn't function propertly. If I use the code
everything works as intended. So how do i get the addKeyListener-function to recognize my method? I tried
But both to no avail.
I am currently making a function that creates keylisteners and callbacks on the fly, and adds them to an element. I've got it all working, except for one thing: I cannot get the addKeyListener method to recognize my new method correctly. The code to do so seems to be quite simple:
- Code: Select all
/** @type {JSMethod} */
var method = solutionForm.newMethod(methodCode);
plugins.keyListener.addKeyListener('keyListener_' + elementName, method, true);
The first call creates a function called onKeyTxtTest for me. This works properly. It's the second line that doesn't function propertly. If I use the code
- Code: Select all
/** @type {JSMethod} */
var method = solutionForm.newMethod(splitCode.join('\n'));
plugins.keyListener.addKeyListener('keyListener_' + elementName, onKeyTxtTest, true);
everything works as intended. So how do i get the addKeyListener-function to recognize my method? I tried
- Code: Select all
plugins.keyListener.addKeyListener('keyListener_' + elementName, method.getUUID(), true);
plugins.keyListener.addKeyListener('keyListener_' + elementName, method.getName(), true);
But both to no avail.