45961bbfbb
(cherry picked from commit e7615d49a4071fe5b5f192884f142c9f3385211a)
23 lines
563 B
JavaScript
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();
|
|
}
|
|
}
|
|
} |