mirror of
				https://github.com/NativeScript/NativeScript.git
				synced 2025-10-31 16:06:01 +08:00 
			
		
		
		
	feat(dialogs): allow using keyboard enter/return to confirm on iOS (#10799)
This commit is contained in:
		| @ -17,7 +17,7 @@ function addButtonsToAlertController(alertController: UIAlertController, options | ||||
| 		alertController.addAction( | ||||
| 			UIAlertAction.actionWithTitleStyleHandler(options.cancelButtonText, UIAlertActionStyle.Default, () => { | ||||
| 				raiseCallback(callback, false); | ||||
| 			}) | ||||
| 			}), | ||||
| 		); | ||||
| 	} | ||||
|  | ||||
| @ -25,16 +25,16 @@ function addButtonsToAlertController(alertController: UIAlertController, options | ||||
| 		alertController.addAction( | ||||
| 			UIAlertAction.actionWithTitleStyleHandler(options.neutralButtonText, UIAlertActionStyle.Default, () => { | ||||
| 				raiseCallback(callback, undefined); | ||||
| 			}) | ||||
| 			}), | ||||
| 		); | ||||
| 	} | ||||
|  | ||||
| 	if (isString(options.okButtonText)) { | ||||
| 		alertController.addAction( | ||||
| 			UIAlertAction.actionWithTitleStyleHandler(options.okButtonText, UIAlertActionStyle.Default, () => { | ||||
| 		const action = UIAlertAction.actionWithTitleStyleHandler(options.okButtonText, UIAlertActionStyle.Default, () => { | ||||
| 			raiseCallback(callback, true); | ||||
| 			}) | ||||
| 		); | ||||
| 		}); | ||||
| 		alertController.addAction(action); | ||||
| 		alertController.preferredAction = action; // Allows using keyboard enter/return to confirm the dialog | ||||
| 	} | ||||
| } | ||||
|  | ||||
| @ -301,7 +301,7 @@ export function action(...args): Promise<string> { | ||||
| 						alertController.addAction( | ||||
| 							UIAlertAction.actionWithTitleStyleHandler(action, dialogType, (arg: UIAlertAction) => { | ||||
| 								resolve(arg.title); | ||||
| 							}) | ||||
| 							}), | ||||
| 						); | ||||
| 					} | ||||
| 				} | ||||
| @ -311,7 +311,7 @@ export function action(...args): Promise<string> { | ||||
| 				alertController.addAction( | ||||
| 					UIAlertAction.actionWithTitleStyleHandler(options.cancelButtonText, UIAlertActionStyle.Cancel, (arg: UIAlertAction) => { | ||||
| 						resolve(arg.title); | ||||
| 					}) | ||||
| 					}), | ||||
| 				); | ||||
| 			} | ||||
|  | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 Samuel Schultze
					Samuel Schultze