Files
GameStarter/src/js/net/minecraft/client/gui/widgets/GuiKeyButton.js
T
LabyStudio 45961bbfbb convert classes to es6
(cherry picked from commit e7615d49a4071fe5b5f192884f142c9f3385211a)
2022-05-02 04:45:51 +02:00

23 lines
563 B
JavaScript

import GuiButton from "./GuiButton.js";
export default class GuiKeyButton extends GuiButton {
constructor(name, key, x, y, width, height, callback) {
super(name + ": " + key, x, y, width, height, _ => callback(this.key));
this.listening = false;
}
onPress() {
this.listening = true;
this.string = "...";
}
keyTyped(key) {
if (this.listening) {
this.string = name + ": " + key;
this.listening = false;
this.key = key;
this.callback();
}
}
}