mirror of https://github.com/oxen-io/session-ios
				
				
				
			
			You cannot select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
	
	
		
			25 lines
		
	
	
		
			836 B
		
	
	
	
		
			Swift
		
	
		
		
			
		
	
	
			25 lines
		
	
	
		
			836 B
		
	
	
	
		
			Swift
		
	
| 
								 
											8 years ago
										 
									 | 
							
								//
							 | 
						||
| 
								 
											7 years ago
										 
									 | 
							
								//  Copyright (c) 2019 Open Whisper Systems. All rights reserved.
							 | 
						||
| 
								 
											8 years ago
										 
									 | 
							
								//
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								// Based on https://stackoverflow.com/questions/1823317/get-the-current-first-responder-without-using-a-private-api/11768282#11768282
							 | 
						||
| 
								 | 
							
								extension UIResponder {
							 | 
						||
| 
								 | 
							
								    private weak static var firstResponder: UIResponder?
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 
											7 years ago
										 
									 | 
							
								    @objc
							 | 
						||
| 
								 
											8 years ago
										 
									 | 
							
								    public class func currentFirstResponder() -> UIResponder? {
							 | 
						||
| 
								 | 
							
								        firstResponder = nil
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								        // If target (`to:`) is nil, the app sends the message to the first responder,
							 | 
						||
| 
								 | 
							
								        // from whence it progresses up the responder chain until it is handled.
							 | 
						||
| 
								 | 
							
								        UIApplication.shared.sendAction(#selector(setSelfAsFirstResponder(sender:)), to: nil, from: nil, for: nil)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								        return firstResponder
							 | 
						||
| 
								 | 
							
								    }
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    @objc
							 | 
						||
| 
								 | 
							
								    private func setSelfAsFirstResponder(sender: AnyObject) {
							 | 
						||
| 
								 | 
							
								        UIResponder.firstResponder = self
							 | 
						||
| 
								 | 
							
								    }
							 | 
						||
| 
								 | 
							
								}
							 |