Skip to content

Commit 7c3c854

Browse files
committed
issue #4174 fix scale bug for button.
1 parent 6a5ae21 commit 7c3c854

File tree

2 files changed

+72
-6
lines changed

2 files changed

+72
-6
lines changed

extensions/CocoStudio/GUI/UIWidgets/UIButton.js

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,14 @@ ccs.Button = ccs.Widget.extend(/** @lends ccs.Button# */{
156156
this.setBright(this._bright);
157157
},
158158

159+
/**
160+
* Get button is using scale9 renderer or not.
161+
* @returns {Boolean}
162+
*/
163+
isScale9Enabled:function(){
164+
return this._scale9Enabled;
165+
},
166+
159167
/**
160168
* ignoreContentAdaptWithSize
161169
* @param {Boolean} ignore
@@ -348,6 +356,14 @@ ccs.Button = ccs.Widget.extend(/** @lends ccs.Button# */{
348356
this._buttonNormalRenderer.setCapInsets(capInsets);
349357
},
350358

359+
/**
360+
* Get normal renderer cap insets .
361+
* @returns {cc.Rect}
362+
*/
363+
getCapInsetNormalRenderer:function(){
364+
return this._capInsetsNormal;
365+
},
366+
351367
/**
352368
* Sets capinsets for button, if button is using scale9 renderer.
353369
* @param {cc.Rect} capInsets
@@ -360,6 +376,14 @@ ccs.Button = ccs.Widget.extend(/** @lends ccs.Button# */{
360376
this._buttonClickedRenderer.setCapInsets(capInsets);
361377
},
362378

379+
/**
380+
* Get pressed renderer cap insets .
381+
* @returns {cc.Rect}
382+
*/
383+
getCapInsetPressedRenderer:function(){
384+
return this._capInsetsPressed;
385+
},
386+
363387
/**
364388
* Sets capinsets for button, if button is using scale9 renderer.
365389
* @param {cc.Rect} capInsets
@@ -372,6 +396,14 @@ ccs.Button = ccs.Widget.extend(/** @lends ccs.Button# */{
372396
this._buttonDisableRenderer.setCapInsets(capInsets);
373397
},
374398

399+
/**
400+
* Get disable renderer cap insets .
401+
* @returns {cc.Rect}
402+
*/
403+
getCapInsetDisabledRenderer:function(){
404+
return this._capInsetsDisabled;
405+
},
406+
375407
onPressStateChangedToNormal: function () {
376408
this._buttonNormalRenderer.setVisible(true);
377409
this._buttonClickedRenderer.setVisible(false);
@@ -390,8 +422,7 @@ ccs.Button = ccs.Widget.extend(/** @lends ccs.Button# */{
390422
}
391423
} else {
392424
this._buttonNormalRenderer.stopAllActions();
393-
var zoomAction = cc.ScaleTo.create(0.05, this._normalTextureScaleXInSize, this._normalTextureScaleYInSize);
394-
this._buttonNormalRenderer.runAction(zoomAction);
425+
this._buttonNormalRenderer.setScale(this._normalTextureScaleXInSize, this._normalTextureScaleYInSize);
395426
}
396427
},
397428

@@ -416,8 +447,7 @@ ccs.Button = ccs.Widget.extend(/** @lends ccs.Button# */{
416447
this._buttonClickedRenderer.setVisible(true);
417448
this._buttonDisableRenderer.setVisible(false);
418449
this._buttonNormalRenderer.stopAllActions();
419-
var zoomAction = cc.ScaleTo.create(0.05, this._pressedTextureScaleXInSize + 0.1, this._pressedTextureScaleYInSize + 0.1);
420-
this._buttonNormalRenderer.runAction(zoomAction);
450+
this._buttonNormalRenderer.setScale(this._normalTextureScaleXInSize + 0.1, this._normalTextureScaleYInSize + 0.1);
421451
}
422452
},
423453

extensions/CocoStudio/GUI/UIWidgets/UITextField.js

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ ccs.TextField = ccs.Widget.extend(/** @lends ccs.TextField# */{
283283
},
284284

285285
/**
286-
* set touch size
286+
* Set touch size.
287287
* @param {cc.Size} size
288288
*/
289289
setTouchSize: function (size) {
@@ -292,6 +292,14 @@ ccs.TextField = ccs.Widget.extend(/** @lends ccs.TextField# */{
292292
this._touchHeight = size.height;
293293
},
294294

295+
/**
296+
* Get touch size.
297+
* @returns {cc.Size}
298+
*/
299+
getTouchSize:function(){
300+
return cc.size(this._touchWidth,this._touchHeight);
301+
},
302+
295303
/**
296304
* Changes the string value of textField.
297305
* @param {String} text
@@ -323,6 +331,13 @@ ccs.TextField = ccs.Widget.extend(/** @lends ccs.TextField# */{
323331
this.textfieldRendererScaleChangedWithSize();
324332
},
325333

334+
/**
335+
* @returns {String}
336+
*/
337+
getPlaceHolder:function(){
338+
return this._textFieldRender.getPlaceHolder();
339+
},
340+
326341
/**
327342
* @param {cc.Size} size
328343
*/
@@ -331,6 +346,13 @@ ccs.TextField = ccs.Widget.extend(/** @lends ccs.TextField# */{
331346
this.textfieldRendererScaleChangedWithSize();
332347
},
333348

349+
/**
350+
* @returns {Number}
351+
*/
352+
getFontSize:function(){
353+
return this._textFieldRender.getFontSize();
354+
},
355+
334356
/**
335357
* @param {String} name
336358
*/
@@ -339,6 +361,13 @@ ccs.TextField = ccs.Widget.extend(/** @lends ccs.TextField# */{
339361
this.textfieldRendererScaleChangedWithSize();
340362
},
341363

364+
/**
365+
* @returns {String}
366+
*/
367+
getFontName:function(){
368+
return this._textFieldRender.getFontName();
369+
},
370+
342371
/**
343372
* detach with IME
344373
*/
@@ -415,13 +444,20 @@ ccs.TextField = ccs.Widget.extend(/** @lends ccs.TextField# */{
415444
},
416445

417446
/**
418-
* @param {String} enable
447+
* @param {String} styleText
419448
*/
420449
setPasswordStyleText: function (styleText) {
421450
this._textFieldRender.setPasswordStyleText(styleText);
422451
this._passwordStyleText = styleText;
423452
},
424453

454+
/**
455+
* @returns {String}
456+
*/
457+
getPasswordStyleText:function(){
458+
return this._passwordStyleText;
459+
},
460+
425461
update: function (dt) {
426462
if (this.getAttachWithIME()) {
427463
this.attachWithIMEEvent();

0 commit comments

Comments
 (0)