From 3c02b7c6cdc9c5a19efbb0011d3ee35b94088dbd Mon Sep 17 00:00:00 2001 From: WolverinDEV Date: Tue, 29 Sep 2020 15:56:55 +0200 Subject: [PATCH] fixing the general channel tree context menu --- shared/js/ui/tree/Controller.tsx | 4 ++++ shared/js/ui/tree/Definitions.ts | 2 +- shared/js/ui/tree/RendererView.tsx | 9 ++++++++- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/shared/js/ui/tree/Controller.tsx b/shared/js/ui/tree/Controller.tsx index 30efce2a..20167f11 100644 --- a/shared/js/ui/tree/Controller.tsx +++ b/shared/js/ui/tree/Controller.tsx @@ -684,6 +684,10 @@ export function initializeChannelTreeController(events: Registry { + if(event.treeEntryId === 0) { + channelTree.showContextMenu(event.pageX, event.pageY); + return; + } const entry = channelTree.findEntryId(event.treeEntryId); if(!entry) { logWarn(LogCategory.CHANNEL, tr("Tried to open a context menu for an invalid channel tree entry with id %o"), event.treeEntryId); diff --git a/shared/js/ui/tree/Definitions.ts b/shared/js/ui/tree/Definitions.ts index 0ccb5f77..28dbadae 100644 --- a/shared/js/ui/tree/Definitions.ts +++ b/shared/js/ui/tree/Definitions.ts @@ -29,7 +29,7 @@ export type ServerState = { state: "disconnected" } | { state: "connecting", tar export interface ChannelTreeUIEvents { /* actions */ action_toggle_popout: { shown: boolean }, - action_show_context_menu: { treeEntryId: number, pageX: number, pageY: number }, + action_show_context_menu: { treeEntryId: number | 0, pageX: number, pageY: number }, action_start_entry_move: { start: { x: number, y: number }, current: { x: number, y: number } }, action_set_collapsed_state: { treeEntryId: number, state: "collapsed" | "expended" }, action_select: { diff --git a/shared/js/ui/tree/RendererView.tsx b/shared/js/ui/tree/RendererView.tsx index 2bde117d..6f216f19 100644 --- a/shared/js/ui/tree/RendererView.tsx +++ b/shared/js/ui/tree/RendererView.tsx @@ -191,7 +191,14 @@ export class ChannelTreeView extends ReactComponentBase this.onScroll()} ref={this.refContainer} onMouseDown={e => this.onMouseDown(e)} - onMouseMove={e => this.onMouseMove(e)}> + onMouseMove={e => this.onMouseMove(e)} + onContextMenu={event => { + if(event.target !== this.refContainer.current) { return; } + + event.preventDefault(); + this.props.events.fire("action_show_context_menu", { pageY: event.pageY, pageX: event.pageX, treeEntryId: 0 }); + }} + >