Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-10507] iOS: Text/password inputs for AlertDialog

GitHub Issuen/a
TypeNew Feature
PriorityCritical
StatusClosed
ResolutionFixed
Resolution Date2012-09-18T11:56:40.000+0000
Affected Version/sn/a
Fix Version/sn/a
Componentsn/a
Labelsalertdialog, input, password, style, textfield
ReporterHidayet Dogan
AssigneeBetty Tran
Created2012-08-16T02:41:20.000+0000
Updated2017-03-09T22:13:16.000+0000

Description

It would be nice to have text and password inputs can be enabled for AlertDialog. "style" API property can be used for this purpose. (UIAlertView alertViewStyle property). For example:
var dialog = Ti.UI.createAlertDialog({
    title: 'Please enter your name',
    style: Ti.UI.iOS.AlertDialogStyle.PLAIN_TEXT_INPUT /* default is Ti.UI.iOS.AlertDialogStyle.DEFAULT */
});
and the text can be passed to AlertDialog's "click" event (fired by clickedButtonAtIndex).

Comments

  1. Hidayet Dogan 2012-08-21

    I'm going to submit pull request for this feature, here is the functional test code:
    Titanium.UI.setBackgroundColor('#fff');
       
       var win = Titanium.UI.createWindow({  
           title: 'Alert Dialog Style',
           backgroundColor: '#fff',
           layout: 'vertical'
       });
       
       var dialog = Titanium.UI.createAlertDialog({
       	message: 'Sample message...',
       	buttonNames: ['OK', 'Cancel', 'Baska']
       });
       
       dialog.addEventListener('click', function(e) {
       	switch (dialog.style) {
       		case Titanium.UI.iPhone.AlertDialogStyle.PLAIN_TEXT_INPUT:
       			value_label.text = 'Plain Text Input: ' + e.text;
       			break;
       		case Titanium.UI.iPhone.AlertDialogStyle.SECURE_TEXT_INPUT:
       			value_label.text = 'Secure Text Input: ' + e.text;
       			break;
       		case Titanium.UI.iPhone.AlertDialogStyle.LOGIN_AND_PASSWORD_INPUT:
       			value_label.text = 'Login: ' + e.login + ' Password: ' + e.password;
       			break;
       		default:
       			value_label.text = 'Default alert dialog shown. There will be no text or login, password event properties.';
       			break;
       	}
       });
       
       var button_default = Titanium.UI.createButton({
       	top: 10,
       	title: 'Default Dialog',
       	style: Titanium.UI.iPhone.SystemButtonStyle.BORDERED
       });
       
       button_default.addEventListener('click', function(e) {
       	dialog.title = 'Default Dialog';
       	dialog.style = Titanium.UI.iPhone.AlertDialogStyle.DEFAULT;
       	dialog.show();
       });
       
       win.add(button_default);
       
       var button_plain = Titanium.UI.createButton({
       	top: 5,
       	title: 'Plain Text Input Dialog',
       	style: Titanium.UI.iPhone.SystemButtonStyle.BORDERED
       });
       
       button_plain.addEventListener('click', function(e) {
       	dialog.text  = 'Enter text';
       	dialog.style = Titanium.UI.iPhone.AlertDialogStyle.PLAIN_TEXT_INPUT;
       	dialog.show();
       });
       
       win.add(button_plain);
       
       var button_secure = Titanium.UI.createButton({
       	top: 5,
       	title: 'Secure Text Input Dialog',
       	style: Titanium.UI.iPhone.SystemButtonStyle.BORDERED
       });
       
       button_secure.addEventListener('click', function(e) {
       	dialog.title = 'Enter password';
       	dialog.style = Titanium.UI.iPhone.AlertDialogStyle.SECURE_TEXT_INPUT;
       	dialog.show();
       });
       
       win.add(button_secure);
       
       var button_login_and_password = Titanium.UI.createButton({
       	top: 5,
       	title: 'Login and Password Dialog',
       	style: Titanium.UI.iPhone.SystemButtonStyle.BORDERED
       });
       
       button_login_and_password.addEventListener('click', function(e) {
       	dialog.title = 'Enter login and password';
       	dialog.style = Titanium.UI.iPhone.AlertDialogStyle.LOGIN_AND_PASSWORD_INPUT;
       	dialog.show();
       });
       
       win.add(button_login_and_password);
       
       var label = Titanium.UI.createLabel({
       	top: 10,
       	text: 'Dialog Input Value(s):'
       });
       
       win.add(label);
       
       var value_label = Titanium.UI.createLabel({
       	top: 5,
       	text: ''
       });
       
       win.add(value_label);
       
       win.open();
  2. Hidayet Dogan 2012-08-21

    Git commit can be found at https://github.com/appcelerator/titanium_mobile/pull/2789 I've functionally tested with the code below using iOS 5 SDK.
  3. Blain Hamon 2012-09-18

    merge pulled.
  4. Lee Morris 2017-03-09

    Closing ticket as fixed.

JSON Source