From 8ab2990f2015065dd60a02b153dad3d1401067e2 Mon Sep 17 00:00:00 2001 From: jberg Date: Mon, 19 Aug 2019 10:21:31 -0700 Subject: [PATCH] Add some more methods to classes (#871) * Add some more methods to classes * fix test --- modern/src/maki-interpreter/objects.test.js | 4 ---- modern/src/runtime/Container.js | 6 ++++++ modern/src/runtime/GuiObject.js | 14 +++++++++++++- modern/src/runtime/System.js | 4 ++++ 4 files changed, 23 insertions(+), 5 deletions(-) diff --git a/modern/src/maki-interpreter/objects.test.js b/modern/src/maki-interpreter/objects.test.js index a480b297..9aca28df 100644 --- a/modern/src/maki-interpreter/objects.test.js +++ b/modern/src/maki-interpreter/objects.test.js @@ -144,7 +144,6 @@ Array [ "Container.onshowlayout", "Container.onswitchtolayout", "Container.setname", - "Container.setxmlparam", "Container.switchtolayout", "Container.toggle", "DropDownList.additem", @@ -292,7 +291,6 @@ Array [ "GuiObject.getguiy", "GuiObject.getinterface", "GuiObject.getname", - "GuiObject.getparentlayout", "GuiObject.gettopparent", "GuiObject.gototarget", "GuiObject.isactive", @@ -328,7 +326,6 @@ Array [ "GuiObject.screentoclientx", "GuiObject.screentoclienty", "GuiObject.sendaction", - "GuiObject.setalpha", "GuiObject.setenabled", "GuiObject.setfocus", "GuiObject.settargeta", @@ -631,7 +628,6 @@ Array [ "System.sqrt", "System.stop", "System.stringtofloat", - "System.stringtointeger", "System.strleft", "System.strlen", "System.strlower", diff --git a/modern/src/runtime/Container.js b/modern/src/runtime/Container.js index b181406c..2a274888 100644 --- a/modern/src/runtime/Container.js +++ b/modern/src/runtime/Container.js @@ -28,6 +28,12 @@ class Container extends MakiObject { this.parent.js_trigger("js_update"); } + setxmlparam(param, value) { + this.attributes[param] = value; + this.js_trigger("js_update"); + return value; + } + getlayout(id) { return findDescendantByTypeAndId(this, "layout", id); } diff --git a/modern/src/runtime/GuiObject.js b/modern/src/runtime/GuiObject.js index f16d3a6f..c308e4ca 100644 --- a/modern/src/runtime/GuiObject.js +++ b/modern/src/runtime/GuiObject.js @@ -1,5 +1,9 @@ import MakiObject from "./MakiObject"; -import { findDescendantByTypeAndId } from "../utils"; +import { + findDescendantByTypeAndId, + findParentNodeOfType, + unimplementedWarning, +} from "../utils"; class GuiObject extends MakiObject { constructor(node, parent) { @@ -42,6 +46,10 @@ class GuiObject extends MakiObject { return this.parent; } + getparentlayout() { + return findParentNodeOfType(this, new Set(["layout"])); + } + show() { this.visible = true; this.parent.js_trigger("js_update"); @@ -85,6 +93,10 @@ class GuiObject extends MakiObject { this.attributes.minimum_h = h; this.attributes.maximum_h = h; } + + setalpha(alpha) { + unimplementedWarning("setAlpha"); + } } export default GuiObject; diff --git a/modern/src/runtime/System.js b/modern/src/runtime/System.js index b8cf1bbe..95356bed 100644 --- a/modern/src/runtime/System.js +++ b/modern/src/runtime/System.js @@ -59,6 +59,10 @@ class System extends MakiObject { return value.toString(); } + stringtointeger(str) { + return parseInt(str, 10); + } + getprivateint(section, item, defvalue) { unimplementedWarning("getprivateint"); return defvalue;