Keys to start and cancel GIF recording

This commit is contained in:
JannisX11 2024-04-19 13:31:52 +02:00
parent dd0257e70c
commit a61aa664b2

View File

@ -589,6 +589,8 @@ const Screencam = {
}, vars.interval)
vars.frame.classList.add('recording');
key_listener.delete();
}
async function endRecording(render) {
if (!vars.recording) return;
@ -616,6 +618,7 @@ const Screencam = {
}
function cancel() {
vars.frame.remove();
key_listener.delete();
}
function updateCrop() {
if (!options.resolution) {
@ -703,6 +706,19 @@ const Screencam = {
});
controls.append(record_button);
let key_listener = Blockbench.on('press_key', context => {
if (Keybinds.extra.confirm.keybind.isTriggered(context.event)) {
context.capture();
startRecording();
return;
}
if (Keybinds.extra.cancel.keybind.isTriggered(context.event)) {
context.capture();
vars.recording ? endRecording(false) : cancel();
return;
}
})
let stop_button = Interface.createElement('div', {class: 'tool'}, Blockbench.getIconNode('stop'));
stop_button.addEventListener('click', event => {
vars.recording ? endRecording(true) : cancel();