Skip to content

Commit

Permalink
Add tooltip functionality to node titles
Browse files Browse the repository at this point in the history
  • Loading branch information
mar10 committed May 1, 2024
1 parent 23e93ea commit 40ff20a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ First release.
> This section will be removed after the beta phase. <br>
> Note that semantic versioning rules are not strictly followed during this phase.
- v0.8.4: Fix #90: Tooltip is not shown.
- v0.8.4: Fix #90: Add tooltip functionality to node titles

- v0.8.3: Fix #84: After editing a node title a javascript error
"Cannot read properties of null (reading '\_render')" occurs (Chromium).
Expand Down
7 changes: 7 additions & 0 deletions src/wb_node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import {
SetStatusOptions,
SortCallback,
SourceType,
TooltipOption,
TristateType,
WbNodeData,
} from "./types";
Expand Down Expand Up @@ -2626,6 +2627,12 @@ export class WunderbaumNode {
// this.triggerModify("rename"); // TODO
}

/** Set the node tooltip. */
setTooltip(tooltip: TooltipOption): void {
this.tooltip = tooltip;
this.update();
}

_sortChildren(cmp: SortCallback, deep: boolean): void {
const cl = this.children;

Expand Down
7 changes: 4 additions & 3 deletions test/playground.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ const tree = new Wunderbaum({
debugLevel: 4,
// minExpandLevel: 1,
emptyChildListExpandable: true,
tooltip: (e) => {
return `${e.node.title} (${e.node.children?.length || 0})`;
},
// tooltip: (e) => {
// return `${e.node.title} (${e.node.children?.length || 0})`;
// },
// autoCollapse: true,
header: true, //"Playground",
// navigationModeOption: "cell",
Expand Down Expand Up @@ -237,6 +237,7 @@ const tree = new Wunderbaum({
edit: true,
focusTree: true,
});
e.tree.findFirst("Observe")?.setTooltip("This is a tooltip");
},
});
console.log(`Created ${tree}`);
Expand Down

0 comments on commit 40ff20a

Please sign in to comment.