Icon toggling and keyboard shortcut

This commit is contained in:
David Rowe 2017-06-24 12:49:45 +12:00
parent b546d977f4
commit ced9473eb3

View file

@ -15,12 +15,25 @@
var APP_NAME = "EZRECORD",
APP_ICON_INACTIVE = "icons/tablet-icons/avatar-record-i.svg",
APP_ICON_ACTIVE = "icons/tablet-icons/avatar-record-a.svg",
SHORTCUT_KEY = "r", // Ctrl modifier is assumed.
tablet,
button;
button,
isRecording = false;
function toggleRecording() {
isRecording = !isRecording;
button.editProperties({ isActive: isRecording });
// TODO: Start/cancel/finish recording.
}
function onKeyPressEvent(event) {
if (event.isControl && event.text === SHORTCUT_KEY && !event.isMeta && !event.isAlt && !event.isAutoRepeat) {
toggleRecording();
}
}
function onButtonClicked() {
// TODO
print("Clicked");
toggleRecording();
}
function setUp() {
@ -39,9 +52,15 @@
if (button) {
button.clicked.connect(onButtonClicked);
}
Controller.keyPressEvent.connect(onKeyPressEvent);
}
function tearDown() {
if (isRecording) {
// TODO: Cancel recording.
}
if (!tablet) {
return;
}
@ -53,6 +72,8 @@
}
tablet = null;
Controller.keyPressEvent.disconnect(onKeyPressEvent);
}
setUp();