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", var APP_NAME = "EZRECORD",
APP_ICON_INACTIVE = "icons/tablet-icons/avatar-record-i.svg", APP_ICON_INACTIVE = "icons/tablet-icons/avatar-record-i.svg",
APP_ICON_ACTIVE = "icons/tablet-icons/avatar-record-a.svg", APP_ICON_ACTIVE = "icons/tablet-icons/avatar-record-a.svg",
SHORTCUT_KEY = "r", // Ctrl modifier is assumed.
tablet, 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() { function onButtonClicked() {
// TODO toggleRecording();
print("Clicked");
} }
function setUp() { function setUp() {
@ -39,9 +52,15 @@
if (button) { if (button) {
button.clicked.connect(onButtonClicked); button.clicked.connect(onButtonClicked);
} }
Controller.keyPressEvent.connect(onKeyPressEvent);
} }
function tearDown() { function tearDown() {
if (isRecording) {
// TODO: Cancel recording.
}
if (!tablet) { if (!tablet) {
return; return;
} }
@ -53,6 +72,8 @@
} }
tablet = null; tablet = null;
Controller.keyPressEvent.disconnect(onKeyPressEvent);
} }
setUp(); setUp();