mirror of
				https://github.com/ArthurSonzogni/FTXUI.git
				synced 2025-11-04 05:28:15 +08:00 
			
		
		
		
	Add the Button component.
This commit is contained in:
		
				
					committed by
					
						
						Arthur Sonzogni
					
				
			
			
				
	
			
			
			
						parent
						
							81d79d311d
						
					
				
				
					commit
					5a8ed208da
				
			
							
								
								
									
										26
									
								
								src/ftxui/component/button.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										26
									
								
								src/ftxui/component/button.cpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,26 @@
 | 
			
		||||
#include "ftxui/component/button.hpp"
 | 
			
		||||
 | 
			
		||||
#include <functional>
 | 
			
		||||
 | 
			
		||||
namespace ftxui {
 | 
			
		||||
 | 
			
		||||
Element Button::Render() {
 | 
			
		||||
  if (Focused())
 | 
			
		||||
    return text(label) | border |inverted;
 | 
			
		||||
  else
 | 
			
		||||
    return text(label) | border;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool Button::OnEvent(Event event) {
 | 
			
		||||
  if (event == Event::Return) {
 | 
			
		||||
    on_click();
 | 
			
		||||
    return true;
 | 
			
		||||
  }
 | 
			
		||||
  return false;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
}  // namespace ftxui
 | 
			
		||||
 | 
			
		||||
// Copyright 2020 Arthur Sonzogni. All rights reserved.
 | 
			
		||||
// Use of this source code is governed by the MIT license that can be found in
 | 
			
		||||
// the LICENSE file.
 | 
			
		||||
		Reference in New Issue
	
	Block a user