Add some more methods to classes (#871)

* Add some more methods to classes

* fix test
This commit is contained in:
jberg 2019-08-19 10:21:31 -07:00 committed by Jordan Eldredge
parent eda8d028c2
commit 8ab2990f20
4 changed files with 23 additions and 5 deletions

View file

@ -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",

View file

@ -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);
}

View file

@ -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;

View file

@ -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;