forked from tickbh/VisualUIEditor
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExtInput.js
More file actions
303 lines (273 loc) · 8.74 KB
/
ExtInput.js
File metadata and controls
303 lines (273 loc) · 8.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
let ExtInput = {}
ExtInput.name = 'UIInput'
ExtInput.icon = 'app://res/control/Input.png'
ExtInput.tag = 5
ExtInput.defRes = 'res/default/shurukuang.png'
ExtInput.SetSpriteFrame = function(node, spriteFrame) {
if (spriteFrame && getFullPathForName(spriteFrame)) {
let fullpath = getFullPathForName(spriteFrame)
cc.textureCache.addImage(fullpath, function() {
let anchor = node.getAnchorPoint()
let pos = node.getPosition()
let size = node.getContentSize()
node.initWithSizeAndBackgroundSprite(size, new cc.Scale9Sprite(fullpath))
node.setPosition(pos)
node.setAnchorPoint(anchor)
node._spriteFrame = spriteFrame
})
}
}
ExtInput.GenEmptyNode = function() {
node = new cc.EditBox(cc.size(100, 20), new cc.Scale9Sprite())
node.placeHolder = 'VisualUI'
node.placeholderFontName = 'Arial'
node.placeholderFontColor = cc.Color.GRAY
ExtInput.SetSpriteFrame(node, ExtInput.defRes)
node._className = ExtInput.name
return node
}
ExtInput.GenNodeByData = function(data, parent) {
node = new cc.EditBox(cc.size(data.width || 100, data.height || 20), new cc.Scale9Sprite())
ExtInput.SetNodePropByData(node, data, parent)
node._className = ExtInput.name
return node
}
ExtInput.SetNodePropByData = function(node, data, parent) {
data.string && (node.string = data.string)
data.fontSize && (node.fontSize = data.fontSize)
data.fontName && (node.fontName = data.fontName);
(covertToColor(data.fontColor)) && (node.fontColor = covertToColor(data.fontColor))
data.maxLength && (node.maxLength = data.maxLength)
data.placeHolder && (node.placeHolder = data.placeHolder)
data.placeHolderFontName && (node.placeHolderFontName = data.placeHolderFontName)
data.placeHolderFontSize && (node.placeHolderFontSize = data.placeHolderFontSize);
(covertToColor(data.placeholderFontColor)) && (node.placeholderFontColor = covertToColor(data.placeholderFontColor));
!isNull(data.inputFlag) && (node.inputFlag = data.inputFlag);
!isNull(data.inputMode) && (node.inputMode = data.inputMode);
!isNull(data.returnType) && (node.returnType = data.returnType);
ExtInput.SetSpriteFrame(node, data.spriteFrame)
}
ExtInput.GetLoadImages = function(data) {
return [data['spriteFrame']]
}
ExtInput.ExportNodeData = function(node, data) {
(node.string.length > 0) && (data['string'] = node.string)
let value = null
value = node._edFontName;
(value.length > 0) && (data['fontName'] = value)
value = node._edFontSize;
(value != 14) && (data['fontSize'] = value)
value = node._textColor;
(!cc.colorEqual(value, cc.color.BLACK)) && (data['fontColor'] = [value.r, value.g, value.b, value.a]);
(node._editBoxInputFlag != cc.EDITBOX_INPUT_FLAG_SENSITIVE) && (data['inputFlag'] = node._editBoxInputFlag);
(node._editBoxInputMode != cc.EDITBOX_INPUT_MODE_ANY) && (data['inputMode'] = node._editBoxInputMode);
(node._keyboardReturnType != cc.KEYBOARD_RETURNTYPE_DEFAULT) && (data['returnType'] = node._keyboardReturnType);
(node.maxLength != 50) && (data['maxLength'] = node.maxLength);
(node.placeHolder && node.placeHolder.length > 0) && (data['placeHolder'] = node.placeHolder)
value = node._placeholderFontName;
(value.length > 0) && (data['placeHolderFontName'] = value)
value = node._placeholderFontSize;
(value != 14) && (data['placeHolderFontSize'] = value)
value = node._placeholderColor || cc.color.GRAY;
(!cc.colorEqual(value, cc.color.GRAY)) && (data['placeholderFontColor'] = [value.r, value.g, value.b, value.a])
value = node._spriteFrame;
(value && value.length > 0) && (data['spriteFrame'] = value)
}
ExtInput.SetPropChange = function(control, path, value) {
SetDefaultPropChange(control, path, value)
}
ExtInput.NodifyPropChange = function(control) {
SetNodifyPropChange(control)
}
ExtInput.ExportData = function(node) {
this._node = node
}
ExtInput.ExportData.prototype = {
__displayName__: 'UIInput',
__type__: 'cc.Input',
get spriteFrame() {
return {
path: 'spriteFrame',
type: 'asset',
name: 'spriteFrame',
attrs: {},
value: this._node._spriteFrame
}
},
get string() {
return {
path: 'string',
type: 'input',
name: 'string',
attrs: {},
value: this._node.string
}
},
get fontName() {
return {
path: 'fontName',
type: 'input',
name: 'fontName',
attrs: {},
value: this._node._edFontName
}
},
get fontSize() {
return {
path: 'fontSize',
type: 'unit-input',
name: 'fontSize',
attrs: {
expand: true,
step: 1,
precision: 0,
min: 0,
max: 72
},
value: this._node._edFontSize
}
},
get fontColor() {
return {
path: 'fontColor',
type: 'color',
name: 'fontColor',
attrs: {},
value: this._node._textColor
}
},
get maxLength() {
return {
path: 'maxLength',
type: 'unit-input',
name: 'maxLength',
attrs: {
expand: true,
step: 1,
precision: 0,
min: 0
},
value: this._node.maxLength
}
},
get placeHolderString() {
return {
path: 'placeHolder',
type: 'input',
name: 'placeHolder',
attrs: {},
value: this._node.placeHolder
}
},
get placeHolderFontName() {
return {
path: 'placeholderFontName',
type: 'input',
name: 'placeHolderFontName',
attrs: {},
value: this._node._placeholderFontName
}
},
get placeHolderFontSize() {
return {
path: 'placeHolderFontSize',
type: 'unit-input',
name: 'placeHolderFontSize',
attrs: {
expand: true,
step: 1,
precision: 0,
min: 0,
max: 72
},
value: this._node._placeholderFontSize
}
},
get placeHolderFontColor() {
return {
path: 'placeholderFontColor',
type: 'color',
name: 'placeholderFontColor',
attrs: {},
value: this._node._placeholderColor || cc.Color.BLACK
}
},
get inputFlag() {
return {
path: 'inputFlag',
type: 'select',
name: 'inputFlag',
attrs: {
selects: {
0: 'PASSWORD',
1: 'SENSITIVE',
2: 'INITIAL_CAPS_WORD',
3: 'INITIAL_CAPS_SENTENCE',
4: 'INITIAL_CAPS_ALL_CHARACTERS'
}
},
value: this._node._editBoxInputFlag
}
},
get inputMode() {
return {
path: 'inputMode',
type: 'select',
name: 'inputMode',
attrs: {
selects: {
0: 'ANY',
1: 'EMAIL_ADDR',
2: 'NUMERIC',
3: 'PHONE_NUMBER',
4: 'URL',
5: 'DECIMAL',
6: 'SINGLE_LINE'
}
},
value: this._node._editBoxInputMode
}
},
get returnType() {
return {
path: 'returnType',
type: 'select',
name: 'returnType',
attrs: {
selects: {
0: 'DEFAULT',
1: 'DONE',
2: 'SEND',
3: 'SEARCH',
4: 'GO'
}
},
value: this._node._keyboardReturnType
}
},
get __props__() {
return [
this.spriteFrame,
this.string,
this.fontName,
this.fontSize,
this.fontColor,
this.inputFlag,
this.inputMode,
this.returnType,
this.maxLength,
this.placeHolderString,
this.placeHolderFontName,
this.placeHolderFontSize,
this.placeHolderFontColor
]
}
}
ExtInput.PropComps = function(node) {
let datas = [new WidgetData(node)]
datas.push(new TouchData(node))
datas.push(new ExtInput.ExportData(node))
return datas
}
module.exports = ExtInput
RegisterExtNodeControl(ExtInput.name, ExtInput)