Commit fe74de1f authored by nerrons's avatar nerrons
Browse files

Fix: scrolling the canvas screws up xlet tooltip positions

parent 7b1c2350
Pipeline #1638 failed with stage
in 0 seconds
......@@ -2239,7 +2239,7 @@ function gui_gobj_draw_io(cid, parenttag, tag, x1, y1, x2, y2, basex, basey,
xlet_class = "xlet_control";
xlet_id = tag + type + i;
}
if (k12_mode === 1) {
if (k12_mode === 1 && type) {
xlet_class += " xlet_tt" + type; // used to determine the position of the tooltip
}
rect = create_item(cid, "rect", {
......@@ -2287,7 +2287,7 @@ function gui_gobj_configure_io(cid, tag, is_iemgui, is_signal, width) {
} else if (is_signal) {
type = "xlet_signal";
} else {
"xlet_control";
type = "xlet_control";
}
e.classList.add(type);
e.classList.remove("xlet_selected");
......@@ -2300,23 +2300,32 @@ function gui_gobj_configure_io(cid, tag, is_iemgui, is_signal, width) {
}
function gui_gobj_highlight_io(cid, tag) {
gui(cid).get_elem(tag, function(e) {
e.classList.add("xlet_selected");
gui(cid).get_nw_window(function (nw_win) {
var xlet = nw_win.window.document.getElementById(tag);
if (xlet) {
xlet.classList.add("xlet_selected");
// for K12 abstraction xlets, show tooltips at mouse position
if (k12_mode === 1
&& (e.classList.contains("xlet_tti") || e.classList.contains("xlet_tto"))) {
gui(cid).get_elem("xlet_tt", function(tt) {
var e_rect = e.getBoundingClientRect(),
e_x = e_rect.left,
e_y = e_rect.top;
tt.innerHTML = k12_xlet_tt[e.parentNode.getAttribute("ttid")][tag.slice(-2)];
&& (xlet.classList.contains("xlet_tti") || xlet.classList.contains("xlet_tto"))) {
var tt = nw_win.window.document.getElementById("xlet_tt"),
xlet_rect = xlet.getBoundingClientRect(),
xlet_x = xlet_rect.left,
xlet_y = xlet_rect.top,
win_left = nw_win.window.document.body.scrollLeft,
win_top = nw_win.window.document.body.scrollTop,
abstraction_tt = k12_xlet_tt[xlet.parentNode.getAttribute("ttid")];
if (abstraction_tt) {
tt.innerHTML = abstraction_tt[tag.slice(-2)];
tt.style.display = "block";
tt.style.left = e_x + 10 + "px";
if (e.classList.contains("xlet_tti")) {
tt.style.top = e_y + 3 + "px";
tt.style.left = xlet_x + win_left + 10 + "px";
if (xlet.classList.contains("xlet_tti")) {
tt.style.top = xlet_y + win_top + 3 + "px";
} else {
tt.style.top = e_y - 10 + "px";
var tt_height = tt.offsetHeight;
tt.style.top = xlet_y + win_top - tt_height + "px";
}
}
}
});
}
});
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment