*Disabled Game-Input while in InputField
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
import game, { GlobalData } from "..";
|
||||
import { INSPECT_MAX_BYTES } from "buffer";
|
||||
let disableInputTimer;
|
||||
|
||||
export default class InputHelper {
|
||||
private title: string;
|
||||
@@ -26,20 +28,24 @@ export default class InputHelper {
|
||||
|
||||
mp.events.add('closeinputhelper', this.finish);
|
||||
|
||||
mp.events.add("render", () => {
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
show() {
|
||||
if (this.created) return;
|
||||
|
||||
this.data.InMenu = true;
|
||||
this.data.InInput = true;
|
||||
this.created = true;
|
||||
this.browser = mp.browsers.new('package://assets/html/inputhelper/index.html');
|
||||
mp.gui.cursor.show(true, true);
|
||||
disableInputTimer = setInterval(disableInput, 1);
|
||||
}
|
||||
|
||||
private finish() {
|
||||
if (this.browser) {
|
||||
clearInterval(disableInputTimer);
|
||||
mp.events.remove('cef_inputhelper_sendvalue');
|
||||
mp.events.remove('cef_request_title');
|
||||
this.browser.destroy();
|
||||
@@ -48,6 +54,7 @@ export default class InputHelper {
|
||||
this.created = false;
|
||||
this.browser = null;
|
||||
mp.gui.cursor.show(false, false);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,14 +75,16 @@ export default class InputHelper {
|
||||
resolve(this.value);
|
||||
});
|
||||
}
|
||||
|
||||
async getValue(callback: Function) {
|
||||
var getVal = await this.valueGetter();
|
||||
callback(getVal);
|
||||
}
|
||||
}
|
||||
|
||||
function disableInput() {
|
||||
for (var x = 0; x < 32; x++) {
|
||||
mp.game.controls.disableAllControlActions(x);
|
||||
}
|
||||
}
|
||||
|
||||
exports = InputHelper;
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user