Skip to content

Commit 2f31621

Browse files
committed
Add tooltip if any in annotations layer
1 parent 50958c4 commit 2f31621

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

src/core/annotation.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -1366,6 +1366,7 @@ class ButtonWidgetAnnotation extends WidgetAnnotation {
13661366

13671367
this.checkedAppearance = null;
13681368
this.uncheckedAppearance = null;
1369+
this.data.isTooltipOnly = false;
13691370

13701371
this.data.checkBox =
13711372
!this.hasFieldFlag(AnnotationFieldFlag.RADIO) &&
@@ -1596,11 +1597,13 @@ class ButtonWidgetAnnotation extends WidgetAnnotation {
15961597
}
15971598

15981599
_processPushButton(params) {
1599-
if (!params.dict.has("A")) {
1600+
if (!params.dict.has("A") && !params.dict.has("TU")) {
16001601
warn("Push buttons without action dictionaries are not supported");
16011602
return;
16021603
}
16031604

1605+
this.data.isTooltipOnly = !params.dict.has("A");
1606+
16041607
Catalog.parseDestDictionary({
16051608
destDict: params.dict,
16061609
resultObj: this.data,

src/display/annotation_layer.js

+10-2
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,10 @@ class AnnotationElement {
165165
let width = data.rect[2] - data.rect[0];
166166
let height = data.rect[3] - data.rect[1];
167167

168+
if (this.data.alternativeText) {
169+
container.setAttribute("title", this.data.alternativeText);
170+
}
171+
168172
container.setAttribute("data-annotation-id", data.id);
169173

170174
// Do *not* modify `data.rect`, since that will corrupt the annotation
@@ -293,8 +297,10 @@ class LinkAnnotationElement extends AnnotationElement {
293297
const isRenderable = !!(
294298
parameters.data.url ||
295299
parameters.data.dest ||
296-
parameters.data.action
300+
parameters.data.action ||
301+
parameters.data.isTooltipOnly
297302
);
303+
298304
super(parameters, isRenderable);
299305
}
300306

@@ -322,8 +328,10 @@ class LinkAnnotationElement extends AnnotationElement {
322328
});
323329
} else if (data.action) {
324330
this._bindNamedAction(link, data.action);
325-
} else {
331+
} else if (data.dest) {
326332
this._bindLink(link, data.dest);
333+
} else {
334+
this._bindLink(link, "");
327335
}
328336

329337
this.container.appendChild(link);

0 commit comments

Comments
 (0)