Fix: setInputTextWidth for InputTypeText

This commit is contained in:
2018-12-09 18:12:13 +09:00
parent 2b6a0cf721
commit 8e1779182d
3 changed files with 148 additions and 92 deletions
+8 -6
View File
@@ -69,7 +69,8 @@ RoundRectButtonSetting.DEFAULT_TEXT_FONT = {
font: "30px Arial",
boundsAlignH: "center", // left, center. right
boundsAlignV: "middle", // top, middle, bottom
fill: "#fff"
fill: "#fff",
align: "center"
};
RoundRectButtonSetting.DEFAULT_TEXT_LINE_SPACING_PX = -10; // in pixel
@@ -164,14 +165,15 @@ RoundRectButton.prototype.makeIcon = function(iconName) {
}
RoundRectButton.prototype.makeText = function(textContent) {
var width = this.setting.width - this.setting.strokeWidthPx * 2;
var height = this.setting.height - this.setting.strokeWidthPx * 2;
var width = this.setting.width / 2 - this.setting.strokeWidthPx;
var height = this.setting.height / 2;
var btnText = game.add.text(0, 0, textContent, this.setting.fontStyle)
.setTextBounds(0, 0, width, this.setting.height);
// var btnText = game.add.text(0, 0, textContent, this.setting.fontStyle)
// .setTextBounds(0, 0, width, this.setting.height);
var btnText = game.add.text(width, height, textContent, this.setting.fontStyle);
btnText.anchor.set(0.5);
btnText.lineSpacing = RoundRectButtonSetting.DEFAULT_TEXT_LINE_SPACING_PX;
// btnText.anchor.setTo(0.5);
return btnText;
}
+14
View File
@@ -29,6 +29,20 @@ function InputTypeText(x, y) {
return myInput;
}
function setInputTextWidth(inputText, width) {
// var inputText = this.makeInputTypeText(game.world.centerX, game.world.centerY, "text");
// setInputTextWidth(inputText, 100);
inputText.canvasInput.width = width;
inputText.canvasInput._shadowCanvas.setAttribute('width', self._width + self._padding * 2);
inputText.canvasInput._hiddenInput.style.width = self._width + 'px';
inputText.canvasInput._width = width;
inputText.canvasInput._calcWH();
inputText.canvasInput._updateCanvasWH();
inputText.canvasInput.render();
}
/*!