mirror of
https://github.com/slint-ui/slint.git
synced 2025-09-30 05:44:52 +00:00
Be able to read or write properties from JS
This commit is contained in:
parent
2e0a5ddb25
commit
7a8c549625
4 changed files with 93 additions and 19 deletions
|
@ -2,9 +2,20 @@
|
|||
native = require('../native/index.node');
|
||||
|
||||
require.extensions['.60'] =
|
||||
function(module, filename) {
|
||||
var c = native.load(filename);
|
||||
module.exports[c.name()] = function(init_properties) { return c.create(init_properties); }
|
||||
}
|
||||
function (module, filename) {
|
||||
var c = native.load(filename);
|
||||
module.exports[c.name()] = function (init_properties) {
|
||||
let comp = c.create(init_properties);
|
||||
let ret = { show() { comp.show() } };
|
||||
c.properties().forEach(x => {
|
||||
Object.defineProperty(ret, x, {
|
||||
get() { return comp.get_property(x); },
|
||||
set(newValue) { comp.set_property(x, newValue); },
|
||||
enumerable: true,
|
||||
})
|
||||
});
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = native;
|
||||
module.exports = native;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue