From 11441c306c85ca562f8410ebfb056c6a414fefc9 Mon Sep 17 00:00:00 2001 From: jberg Date: Sun, 18 Aug 2019 13:01:26 -0700 Subject: [PATCH] fix container after inheritance change (#859) * fix container after inheritance change * fix missing method test --- modern/src/App.js | 9 ++++++--- modern/src/maki-interpreter/objects.test.js | 2 -- modern/src/runtime/Container.js | 16 ++++++++++++++++ 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/modern/src/App.js b/modern/src/App.js index 6e1e2058..0d90d4dc 100644 --- a/modern/src/App.js +++ b/modern/src/App.js @@ -28,8 +28,8 @@ function handleMouseEventDispatch(node, event, eventName) { ); const clientX = event.clientX; const clientY = event.clientY; - const x = clientX - container.getleft(); - const y = clientY - container.gettop(); + const x = clientX - (Number(container.attributes.x) || 0); + const y = clientY - (Number(container.attributes.y) || 0); node.js_trigger(eventName, x, y); if (event.nativeEvent.type === "mousemove") { @@ -468,7 +468,10 @@ function XmlNode({ node }) { const Component = NODE_NAME_TO_COMPONENT[name]; const childNodes = node.children || []; const children = childNodes.map( - (childNode, i) => childNode.visible && + (childNode, i) => + (childNode.visible || childNode.visible === undefined) && ( + + ) ); if (Component == null) { console.warn("Unknown node type", name); diff --git a/modern/src/maki-interpreter/objects.test.js b/modern/src/maki-interpreter/objects.test.js index 3f8c7778..144ae446 100644 --- a/modern/src/maki-interpreter/objects.test.js +++ b/modern/src/maki-interpreter/objects.test.js @@ -138,7 +138,6 @@ Array [ "Container.enumlayout", "Container.getcurlayout", "Container.getnumlayouts", - "Container.hide", "Container.isdynamic", "Container.onbeforeswitchtolayout", "Container.onhidelayout", @@ -146,7 +145,6 @@ Array [ "Container.onswitchtolayout", "Container.setname", "Container.setxmlparam", - "Container.show", "Container.switchtolayout", "Container.toggle", "DropDownList.additem", diff --git a/modern/src/runtime/Container.js b/modern/src/runtime/Container.js index 855e6a91..b181406c 100644 --- a/modern/src/runtime/Container.js +++ b/modern/src/runtime/Container.js @@ -2,6 +2,12 @@ import MakiObject from "./MakiObject"; import { findDescendantByTypeAndId } from "../utils"; class Container extends MakiObject { + constructor(node, parent) { + super(node, parent); + + this.visible = true; + } + /** * getclassname() * @@ -12,6 +18,16 @@ class Container extends MakiObject { return "Container"; } + show() { + this.visible = true; + this.parent.js_trigger("js_update"); + } + + hide() { + this.visible = false; + this.parent.js_trigger("js_update"); + } + getlayout(id) { return findDescendantByTypeAndId(this, "layout", id); }