Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 08a0144

Browse files
committedJan 10, 2025·
browser: treeview: add 'dblclick' event handler
Change-Id: Ied04405a87e8d9b5d45d192f4f244262b2fdc9a7 Signed-off-by: Henry Castro <hcastro@collabora.com>
1 parent 0c3ef91 commit 08a0144

File tree

1 file changed

+23
-61
lines changed

1 file changed

+23
-61
lines changed
 

‎browser/src/control/jsdialog/Widget.TreeView.ts

+23-61
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ class TreeViewControl {
108108

109109
if (data.enabled !== false) {
110110
this._container.addEventListener('click', this.onClick.bind(this));
111+
this._container.addEventListener('dblclick', this.onDoubleClick.bind(this));
111112
}
112113
}
113114

@@ -552,34 +553,13 @@ class TreeViewControl {
552553
}
553554
}
554555

555-
/*var doubleClickFunction = this.createClickFunction(
556-
tr,
557-
selectionElement,
558-
false,
559-
true,
560-
builder,
561-
treeViewData,
562-
entry,
563-
);
564-
565-
this.setupEntryMouseEvents(
566-
tr,
567-
entry,
568-
treeViewData,
569-
builder,
570-
selectionElement,
571-
expander,
572-
clickFunction,
573-
doubleClickFunction,
574-
);
575-
576-
this.setupEntryKeyEvent(
556+
/*this.setupEntryKeyEvent(
577557
tr,
578558
entry,
579559
selectionElement,
580560
expander,
581561
clickFunction,
582-
); */
562+
);*/
583563

584564
this.setupEntryContextMenuEvent(tr, entry, treeViewData, builder);
585565
}
@@ -602,44 +582,6 @@ class TreeViewControl {
602582
});
603583
}
604584

605-
setupEntryMouseEvents(
606-
tr: HTMLElement,
607-
entry: TreeEntryJSON,
608-
treeViewData: TreeWidgetJSON,
609-
builder: any,
610-
selectionElement: HTMLInputElement,
611-
expander: HTMLElement,
612-
clickFunction: any,
613-
doubleClickFunction: any,
614-
) {
615-
tr.addEventListener('click', clickFunction as any);
616-
617-
if (!this._singleClickActivate) {
618-
if (window.ThisIsTheiOSApp) {
619-
// TODO: remove this hack
620-
tr.addEventListener('click', () => {
621-
if (L.DomUtil.hasClass(tr, 'disabled')) return;
622-
623-
if (
624-
entry.row == lastClickHelperRow &&
625-
treeViewData.id == lastClickHelperId
626-
)
627-
doubleClickFunction(undefined);
628-
else {
629-
lastClickHelperRow = entry.row;
630-
lastClickHelperId = treeViewData.id;
631-
setTimeout(() => {
632-
lastClickHelperRow = -1;
633-
}, 300);
634-
}
635-
});
636-
// TODO: remove this hack
637-
} else {
638-
$(tr).dblclick(doubleClickFunction as any);
639-
}
640-
}
641-
}
642-
643585
setupEntryKeyEvent(
644586
tr: HTMLElement,
645587
entry: TreeEntryJSON,
@@ -1212,6 +1154,26 @@ class TreeViewControl {
12121154
this.toggleEntry(expander, this._data, expander._row, this._builder);
12131155
}
12141156
}
1157+
1158+
onDoubleClick(e: any) {
1159+
let target = e.target;
1160+
let row = TreeViewControl.getElement(target, 'row');
1161+
if (row && !L.DomUtil.hasClass(row, 'disabled')) {
1162+
this.onRowDoubleClick(row);
1163+
}
1164+
}
1165+
1166+
onRowDoubleClick(row: any) {
1167+
if (!this._singleClickActivate) {
1168+
this._builder.callback(
1169+
'treeview',
1170+
'activate',
1171+
this._data,
1172+
row._row,
1173+
this._builder,
1174+
);
1175+
}
1176+
}
12151177
}
12161178

12171179
JSDialog.treeView = function (

0 commit comments

Comments
 (0)
Please sign in to comment.