我在famo.us 大学上没有看到任何带有文本输入的教程。如何将文本框表面添加到我的应用程序并处理onchange
events?
有点难以理解你想要做什么。但是让我们从你的第一个问题开始。目前没有 onchange 处理程序选项,因此如果您现在需要它,您可以编写 InputSurface 的子类。通过重写部署函数,同时仍然调用InputSurface的部署函数,我们可以添加我们想要的功能,而不需要搞太多事情!
您可以通过以下方法将 onchange 处理程序添加到 InputSurface 的子类中。请再次记住 onchange 仅在 InputSurface 模糊后触发。
祝你好运!
var Engine = require('famous/core/Engine');
var Surface = require('famous/core/Surface');
var StateModifier = require('famous/modifiers/StateModifier');
var EventHandler = require('famous/core/EventHandler')
var InputSurface = require('famous/surfaces/InputSurface')
function MyInputSurface(options) {
InputSurface.apply(this, arguments);
this.onchange = options.onchange;
this._superDeploy = InputSurface.prototype.deploy;
}
MyInputSurface.prototype = Object.create(InputSurface.prototype);
MyInputSurface.prototype.constructor = MyInputSurface;
MyInputSurface.prototype.deploy = function deploy(target) {
target.onchange = this.onchange;
this._superDeploy(target);
};
var context = Engine.createContext();
var onchangeFunction = function(){ console.log("Text Changed!"); }
var myInput = new MyInputSurface({
size: [200,60],
onchange: onchangeFunction
})
context.add(new StateModifier({origin:[0.5,0.5]})).add(myInput);
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)