diff --git a/frontend/src/ui/container.ts b/frontend/src/ui/container.ts index 9f93545..c8311cc 100644 --- a/frontend/src/ui/container.ts +++ b/frontend/src/ui/container.ts @@ -26,12 +26,14 @@ export class Container extends UINode { this.children.push(node); node._onConnect(); this.containerElement.appendChild(node.render()); + return this; } public remove(node: UINode) { this.children.splice(this.children.indexOf(node), 1); node._onDisconnect(); this.containerElement.removeChild(node.render()); + return this; } public render() { diff --git a/frontend/src/views/main.ts b/frontend/src/views/main.ts index 196fb45..94b7056 100644 --- a/frontend/src/views/main.ts +++ b/frontend/src/views/main.ts @@ -84,38 +84,38 @@ export class MainView extends View { } public onCreate(): void { - this.settingsButton = new Button("Settings"); - this.settingsButton.setPosition(0, 0, 10, 10); - this.settingsButton.onClick(() => this.openSettingsDialog()); - this.channelSwitcher = new Dropdown("Channel", []); - this.channelSwitcher.setPosition(30, 10, 30, 10); - this.channelInfoButton = new Button("Channel info"); - this.channelInfoButton.setPosition(60, 10, 30, 10); - this.searchButton = new Button("Search"); - this.searchButton.setPosition(90, 10, 10, 10); - this.searchButton.onClick(async () => this.openSearchDialog()); + this.settingsButton = new Button("Settings") + .setPosition(0, 0, 10, 10) + .onClick(() => this.openSettingsDialog()); + this.channelSwitcher = new Dropdown("Channel", []) + .setPosition(30, 10, 30, 10); + this.channelInfoButton = new Button("Channel info") + .setPosition(60, 10, 30, 10); + this.searchButton = new Button("Search") + .setPosition(90, 10, 10, 10) + .onClick(async () => this.openSearchDialog()); - this.fileInput = new FileInput("Upload file"); - this.fileInput.setPosition(0, 90, 15, 10); - this.imageInput = new Button("Image"); - this.imageInput.setPosition(15, 90, 15, 10); - this.messageInput = new MultilineInput("New message"); - this.messageInput.setPosition(30, 90, 60, 10); + this.fileInput = new FileInput("Upload file") + .setPosition(0, 90, 15, 10); + this.imageInput = new Button("Image") + .setPosition(15, 90, 15, 10); + this.messageInput = new MultilineInput("New message") + .setPosition(30, 90, 60, 10); this.messageInput.getElement().autofocus = true; - this.voiceMessageInput = new Button("Voice message"); - this.voiceMessageInput.setPosition(70, 90, 30, 10); + this.voiceMessageInput = new Button("Voice message") + .setPosition(70, 90, 30, 10); - this.messageList = new List("Messages"); - this.messageList.setPosition(30, 30, 60, 50); - this.window.add(this.settingsButton); - this.window.add(this.channelSwitcher); - this.window.add(this.channelInfoButton); - this.window.add(this.searchButton); - this.window.add(this.messageList); - this.window.add(this.messageInput); - this.window.add(this.fileInput); - this.window.add(this.imageInput); - this.window.add(this.voiceMessageInput); + this.messageList = new List("Messages") + .setPosition(30, 30, 60, 50); + this.window.add(this.settingsButton) + .add(this.channelSwitcher) + .add(this.channelInfoButton) + .add(this.searchButton) + .add(this.messageList) + .add(this.messageInput) + .add(this.fileInput) + .add(this.imageInput) + .add(this.voiceMessageInput); this.channelSwitcher.getElement().addEventListener("change", (e) => this.handleChannelSwitcher(e)); this.voiceMessageInput.onClick(async () => this.handleVoiceMessageButton()); @@ -581,8 +581,9 @@ export class MainView extends View { } private handleHotkey(e: KeyboardEvent) { - if (e.ctrlKey || e.metaKey) { - const action = this.hotkeyMap.get(e.key); + + if (e.ctrlKey && e.shiftKey) { + const action = this.hotkeyMap.get(e.key.toLowerCase()); if (action) { e.preventDefault(); action();