mirror of
				https://github.com/ocornut/imgui.git
				synced 2025-10-26 12:27:30 +00:00 
			
		
		
		
	Closing the focused window restore focus to the first active root window in descending z-order (part of #727)
This commit is contained in:
		
							
								
								
									
										14
									
								
								imgui.cpp
									
									
									
									
									
								
							
							
						
						
									
										14
									
								
								imgui.cpp
									
									
									
									
									
								
							| @@ -2250,16 +2250,13 @@ void ImGui::NewFrame() | |||||||
|                 window->SizeFull *= scale; |                 window->SizeFull *= scale; | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|         else |         else if (!(window->Flags & ImGuiWindowFlags_NoScrollWithMouse)) | ||||||
|         { |         { | ||||||
|             // Scroll |             // Scroll | ||||||
|             if (!(window->Flags & ImGuiWindowFlags_NoScrollWithMouse)) |  | ||||||
|             { |  | ||||||
|             const int scroll_lines = (window->Flags & ImGuiWindowFlags_ComboBox) ? 3 : 5; |             const int scroll_lines = (window->Flags & ImGuiWindowFlags_ComboBox) ? 3 : 5; | ||||||
|             SetWindowScrollY(window, window->Scroll.y - g.IO.MouseWheel * window->CalcFontSize() * scroll_lines); |             SetWindowScrollY(window, window->Scroll.y - g.IO.MouseWheel * window->CalcFontSize() * scroll_lines); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|     } |  | ||||||
|  |  | ||||||
|     // Pressing TAB activate widget focus |     // Pressing TAB activate widget focus | ||||||
|     // NB: Don't discard FocusedWindow if it isn't active, so that a window that go on/off programatically won't lose its keyboard focus. |     // NB: Don't discard FocusedWindow if it isn't active, so that a window that go on/off programatically won't lose its keyboard focus. | ||||||
| @@ -2275,6 +2272,15 @@ void ImGui::NewFrame() | |||||||
|         window->Accessed = false; |         window->Accessed = false; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     // Closing the focused window restore focus to the first active root window in descending z-order | ||||||
|  |     if (g.FocusedWindow && !g.FocusedWindow->WasActive) | ||||||
|  |         for (int i = g.Windows.Size-1; i >= 0; i--) | ||||||
|  |             if (g.Windows[i]->WasActive && !(g.Windows[i]->Flags & ImGuiWindowFlags_ChildWindow)) | ||||||
|  |             { | ||||||
|  |                 FocusWindow(g.Windows[i]); | ||||||
|  |                 break; | ||||||
|  |             } | ||||||
|  |  | ||||||
|     // No window should be open at the beginning of the frame. |     // No window should be open at the beginning of the frame. | ||||||
|     // But in order to allow the user to call NewFrame() multiple times without calling Render(), we are doing an explicit clear. |     // But in order to allow the user to call NewFrame() multiple times without calling Render(), we are doing an explicit clear. | ||||||
|     g.CurrentWindowStack.resize(0); |     g.CurrentWindowStack.resize(0); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 ocornut
					ocornut