Keyboard icon indicating copy to clipboard operation
Keyboard copied to clipboard

how to raise event from inside actionKey function ?

Open debanjana opened this issue 8 years ago • 3 comments

I am trying to do something like

$.keyboard.keyaction.plusbtn = function (base) {
  this.incrementKeyPress.emit(1); // where increment key press is an event Event emmiter defined in the 
  // component as below
  //  @Output() incrementKeyPress: EventEmitter<any> = new EventEmitter();

I get an error saying " cant call emit of undefined" I understand incrementKeyPress is undefined because "this" is not a reference to the component but the keyboard. How do I call the event emmiter from here.

debanjana avatar Feb 02 '18 02:02 debanjana

Hi @debanjana!

The this in the example would reference the function wrapping the code. Please share more of your code, especially the code containing incrementKeyPress so I can better help you.

Mottie avatar Feb 02 '18 03:02 Mottie

Since this plugin uses jQuery, would using .trigger() work for you?

Mottie avatar Feb 02 '18 13:02 Mottie

Hi Rob :) , Thank you for your reply. I kind of figured something out and I did as below :

$.keyboard.keyaction.plusbtn = function (this, base) {
      // console.log('base.settings', base.settings.index);
      if (base.settings.specialActionCallback) {
        base.settings.specialActionCallback({ action: 'add', index: base.settings.index});
      }
}

and in my parent component I did as below :

getVirtualKeyboardType(parameter: DisplayParameter) {
if (this.showNumericKeypad()) {
      return {
      ...............
    specialActionCallback: this.specialAction.bind(this), 
}

debanjana avatar Feb 03 '18 08:02 debanjana