彼は「ハック」なしでは成し遂げられないようです。Ext.Msgはシングルトンであり、initComponentでテキストフィールドが設定されており、構成できません。 http://docs.sencha.com/ext-js/4-1/source/MessageBox.html#Ext-window-MessageBox-method-initComponent
これはシングルトンであるため、オーバーライドは機能せず、問題の適切な解決策ではありません。
Messageboxの拡張機能は機能するはずですが、MessageBoxコードには多くのフックがないため、Extのアップグレードごとにコードを確認する必要があります。
Ext.define('NumberPrompt', {
extend: 'Ext.window.MessageBox',
initComponent: function() {
this.callParent();
var index = this.promptContainer.items.indexOf(this.textField);
this.promptContainer.remove(this.textField);
this.textField = this._createNumberField();
this.promptContainer.insert(index, this.textField);
},
_createNumberField: function() {
//copy paste what is being done in the initComonent to create the textfield
return new Ext.form.field.Number({
id: this.id + '-textfield',
anchor: '100%',
enableKeyEvents: true,
listeners: {
keydown: this.onPromptKey,
scope: this
}
});
}
});
var msgbox = new NumberPrompt().prompt('Quantity', 'Enter a number',function(btn, text){} )