Skip to content

Commit

Permalink
Add tooltip if any in annotations layer
Browse files Browse the repository at this point in the history
  • Loading branch information
calixteman committed Sep 6, 2020
1 parent 50958c4 commit 2f31621
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/core/annotation.js
Original file line number Diff line number Diff line change
Expand Up @@ -1366,6 +1366,7 @@ class ButtonWidgetAnnotation extends WidgetAnnotation {

this.checkedAppearance = null;
this.uncheckedAppearance = null;
this.data.isTooltipOnly = false;

this.data.checkBox =
!this.hasFieldFlag(AnnotationFieldFlag.RADIO) &&
Expand Down Expand Up @@ -1596,11 +1597,13 @@ class ButtonWidgetAnnotation extends WidgetAnnotation {
}

_processPushButton(params) {
if (!params.dict.has("A")) {
if (!params.dict.has("A") && !params.dict.has("TU")) {
warn("Push buttons without action dictionaries are not supported");
return;
}

this.data.isTooltipOnly = !params.dict.has("A");

Catalog.parseDestDictionary({
destDict: params.dict,
resultObj: this.data,
Expand Down
12 changes: 10 additions & 2 deletions src/display/annotation_layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,10 @@ class AnnotationElement {
let width = data.rect[2] - data.rect[0];
let height = data.rect[3] - data.rect[1];

if (this.data.alternativeText) {
container.setAttribute("title", this.data.alternativeText);
}

container.setAttribute("data-annotation-id", data.id);

// Do *not* modify `data.rect`, since that will corrupt the annotation
Expand Down Expand Up @@ -293,8 +297,10 @@ class LinkAnnotationElement extends AnnotationElement {
const isRenderable = !!(
parameters.data.url ||
parameters.data.dest ||
parameters.data.action
parameters.data.action ||
parameters.data.isTooltipOnly
);

super(parameters, isRenderable);
}

Expand Down Expand Up @@ -322,8 +328,10 @@ class LinkAnnotationElement extends AnnotationElement {
});
} else if (data.action) {
this._bindNamedAction(link, data.action);
} else {
} else if (data.dest) {
this._bindLink(link, data.dest);
} else {
this._bindLink(link, "");
}

this.container.appendChild(link);
Expand Down

0 comments on commit 2f31621

Please sign in to comment.