Skip to content
Snippets Groups Projects
Commit 933d1aca authored by Jonathan Wilkes's avatar Jonathan Wilkes
Browse files

fix #19:

many lines of text inside an Object Box can mess up the GUI viewport
* check when the user types "Enter" in an object or message box, and
  grown the svg viewBox if necessary
This should close the corresponding bug
parent a629b234
No related branches found
No related tags found
No related merge requests found
......@@ -166,12 +166,16 @@ var canvas_events = (function() {
},
grow_svg_for_element= function(elem) {
// See if an element overflows the svg bbox, and
// enlarge the svg to accommodate it
// enlarge the svg to accommodate it.
// Note: window.scrollX and window.scrollY might not work
// with Android Chrome 43 and IE.
var svg = document.getElementById("patchsvg"),
elem_bbox = elem.getBoundingClientRect(),
svg_viewbox = svg.getAttribute("viewBox").split(" "),
w = Math.max(elem_bbox.left + elem_bbox.width, svg_viewbox[2]),
h = Math.max(elem_bbox.top + elem_bbox.height, svg_viewbox[3]);
w = Math.max(elem_bbox.left + elem_bbox.width + window.scrollX,
svg_viewbox[2]),
h = Math.max(elem_bbox.top + elem_bbox.height + window.scrollY,
svg_viewbox[3]);
svg.setAttribute("viewBox",
[Math.min(elem_bbox.left, svg_viewbox[0]),
Math.min(elem_bbox.top, svg_viewbox[1]),
......@@ -433,6 +437,10 @@ var canvas_events = (function() {
},
text_keyup: function(evt) {
evt.stopPropagation();
if (evt.keyCode === 13) {
pdgui.post("growing the svg...");
grow_svg_for_element(textbox());
}
//evt.preventDefault();
return false;
},
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment