0
votes

I've got a nativescript app and I'm using IQKeyboardManager with default settings.

I see there in an option to dismiss the keyboard on tap outside a text field with a typescript example for toggling it on and off:

  private iqKeyboard: IQKeyboardManager;
  public keepKeyboardOpenOnTouchOutside: boolean = true;

  toggleKeepKeyboardOpen(): void {
    this.iqKeyboard.shouldResignOnTouchOutside = !this.iqKeyboard.shouldResignOnTouchOutside;
  }

But I don't understand how to go about it in normal javascript.

I want to set the keepKeyboardOpenOnTouchOutside variable with something like:

exports.loaded = function(args){
   keepKeyboardOpenOnTouchOutside = false;
}

but I don't understand how I'm supposed to access the instance variable properly.

1
Which part you do not understand. If you remove typings from TypeScript, rest is JavaScript. - Manoj
I guess I don't understand how to access the instance variable so I can just set keepKeyboardOpenOnTouchOutside = false;. My lack of understanding may not be simply typescript. - phauwn

1 Answers

0
votes

I missed a step in the documentation:

/// <reference path="./node_modules/tns-platform-declarations/ios/ios.d.ts" />
/// <reference path="./node_modules/nativescript-iqkeyboardmanager/index.d.ts" />

is required in references.d.ts and then I can initialize the variables like so:

const iqKeyboard = IQKeyboardManager.sharedManager();
iqKeyboard.keepKeyboardOpenOnTouchOutside = false;
iqKeyboard.shouldResignOnTouchOutside = true;