I would like to ask that there is a button, and an editbox, on canvas. I click button, and display what I want on editbox. In fact, I just want to simulate a keyboard input function. How can I access the editbox control?
Thank you.
I would like to ask that there is a button, and an editbox, on canvas. I click button, and display what I want on editbox. In fact, I just want to simulate a keyboard input function. How can I access the editbox control?
Thank you.
well, let me talk about my own solution. The cocos creator v1.9.1
I use is actually very simple when I am not familiar with cocos creator, at the beginning.
first put the editbox into the desired scene, where the scene is named main, and hang the script main.js, to the scene main, which means to create the main.js in Explorer and then drag it to the script of canvas's property inspector with the mouse.
then you can write
on properties on main.js.// editbox canvas
editbox:{
default: null,
type: cc.EditBox,
}
continue to put a key button into the scene, also select the button in the level manager, and find Click Events in the property manager to change 0 to 1, so that the button will have an execution method. The value represents how many methods can be hung. The following is dragging the canvas to the first box, and the second box is which script (js), the third box is the method under this script. CustomEventData is the value of this button
for example, we wrote a buttonEvent on main.js
properties:{
editbox:{
default: null,
type: cc.EditBox,
},
button:{
default: null,
type: cc.Button,
}
},
buttonEvent: function (target, value) {
// target value CustomEventData
cc.log(target, value);
this.button.string = value;
}
according to the above, the value of a key can be passed to editbox, simulating the input of the virtual keyboard
well, the above is my method, if there is any other way, please do not hesitate to advise, thank you.