Function for testing handling of figures with UI
This commit is contained in:
		
							parent
							
								
									9d56441c79
								
							
						
					
					
						commit
						4520e1e1d4
					
				
							
								
								
									
										65
									
								
								figure_testing.m
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										65
									
								
								figure_testing.m
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,65 @@ | ||||
| %% function for testing of uifigures and buttons | ||||
| function [] = figure_testing() | ||||
| %% figure with "Apply", "Reset" and "Done" button | ||||
| %create figure | ||||
| fig = figure; | ||||
| fig.Name = 'Test Window'; | ||||
| fig.Units = 'Normalized'; | ||||
| fig.Position = [.2 .2 .6 .6]; | ||||
| fig.Tag = 'Test Window'; | ||||
| 
 | ||||
| %create push buttons | ||||
| a = uicontrol(fig,'Style','pushbutton'); | ||||
| a.String = 'Apply'; | ||||
| a.Units = 'Normalized'; | ||||
| a.Position = [.52 .01 .15 .05]; | ||||
| a.FontUnits = 'Normalized'; | ||||
| a.FontSize = 0.6; | ||||
| a.Tag = 'Apply'; | ||||
| a.Callback = @ApplyButtonPushed; | ||||
| 
 | ||||
| r = uicontrol(fig,'Style','pushbutton'); | ||||
| r.String = 'Reset'; | ||||
| r.Units = 'Normalized'; | ||||
| r.Position = [.68 .01 .15 .05]; | ||||
| r.FontUnits = 'Normalized'; | ||||
| r.FontSize = 0.6; | ||||
| r.Tag = 'Reset'; | ||||
| r.Callback = @ResetButtonPushed; | ||||
| 
 | ||||
| d = uicontrol(fig,'Style','pushbutton'); | ||||
| d.String = 'Done'; | ||||
| d.Units = 'Normalized'; | ||||
| d.Position = [.84 .01 .15 .05]; | ||||
| d.FontUnits = 'Normalized'; | ||||
| d.FontSize = 0.6; | ||||
| d.Tag = 'Done'; | ||||
| d.Callback = @DoneButtonPushed; | ||||
| 
 | ||||
| %create input field | ||||
| inp = uicontrol(fig,'Style','edit'); | ||||
| inp.Units = 'Normalized'; | ||||
| inp.Position = [.01 .01 .5 .05]; | ||||
| inp.HorizontalAlignment = 'left'; | ||||
| inp.FontUnits = 'Normalized'; | ||||
| inp.FontSize = 0.6; | ||||
| % inp.Tag = 'input'; | ||||
| 
 | ||||
| uicontrol(inp); %passes focus to input | ||||
| 
 | ||||
| %% Callback functions | ||||
|     function ApplyButtonPushed(src,event) | ||||
|         out = get(inp,'String'); | ||||
|         txt = strcat("Applied correction by ",out," points!"); | ||||
|         disp(txt) | ||||
|     end | ||||
| 
 | ||||
|     function ResetButtonPushed(src,event) | ||||
|         disp('Resetted data!') | ||||
|     end | ||||
| 
 | ||||
|     function DoneButtonPushed(src,event) | ||||
|         close 'Test Window' | ||||
|     end | ||||
| 
 | ||||
| end | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user