Skip to content

Commit

Permalink
jsdialog: add type for custom rendered entry callback
Browse files Browse the repository at this point in the history
Signed-off-by: Szymon Kłos <[email protected]>
Change-Id: I023890a78991c082769ce00c9b96ada4d978675c
  • Loading branch information
eszkadev committed Jan 22, 2025
1 parent 1a3b4f3 commit 77385db
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 3 additions & 0 deletions browser/src/control/jsdialog/Definitions.Types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ type JSDialogCallback = (
builder: any,
) => void;

// callback triggered for custom rendered entries
type CustomEntryRenderCallback = (pos: number | string) => void;

// used to define menus
type MenuDefinition = {
id: string; // unique identifier
Expand Down
4 changes: 3 additions & 1 deletion browser/src/control/jsdialog/Widget.TreeView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1277,7 +1277,7 @@ JSDialog.treeView = function (
treeView.build(data, builder, parentContainer);
parentContainer.appendChild(treeView._container);

(treeView._container as any).updateRenders = (pos: number | string) => {
const updateRenders: CustomEntryRenderCallback = (pos: number | string) => {
const row = treeView.findEntryWithRow(data.entries, pos);
if (!row) {
console.error('treeview updateRenders: row "' + pos + '" not found');
Expand All @@ -1299,6 +1299,8 @@ JSDialog.treeView = function (
treeView.build(data, builder, parentContainer);
};

(treeView._container as any).updateRenders = updateRenders;

return false;
};

Expand Down

0 comments on commit 77385db

Please sign in to comment.