mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-11-02 20:51:23 -07:00 
			
		
		
		
	Search: Set focus on search line in popup control on Plater
This commit is contained in:
		
							parent
							
								
									8ab7956c26
								
							
						
					
					
						commit
						218abacb75
					
				
					 2 changed files with 17 additions and 2 deletions
				
			
		| 
						 | 
				
			
			@ -4489,7 +4489,7 @@ bool GLCanvas3D::_render_search_list(float pos_x) const
 | 
			
		|||
    char *s = new char[255];
 | 
			
		||||
    strcpy(s, search_line.empty() ? _u8L("Type here to search").c_str() : search_line.c_str());
 | 
			
		||||
 | 
			
		||||
    imgui->search_list(ImVec2(22 * em, 30 * em), &search_string_getter, s, selected, edited);
 | 
			
		||||
    imgui->search_list(ImVec2(36 * em, 30 * em), &search_string_getter, s, selected, edited);
 | 
			
		||||
 | 
			
		||||
    search_line = s;
 | 
			
		||||
    delete [] s;
 | 
			
		||||
| 
						 | 
				
			
			@ -4499,7 +4499,9 @@ bool GLCanvas3D::_render_search_list(float pos_x) const
 | 
			
		|||
 | 
			
		||||
    if (selected != size_t(-1))
 | 
			
		||||
    {
 | 
			
		||||
        wxGetApp().sidebar().jump_to_option(selected);
 | 
			
		||||
        // selected == 9999 means that Esc kye was pressed
 | 
			
		||||
        if (selected != 9999)
 | 
			
		||||
            wxGetApp().sidebar().jump_to_option(selected);
 | 
			
		||||
        action_taken = true;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -570,9 +570,22 @@ void ImGuiWrapper::search_list(const ImVec2& size_, bool (*items_getter)(int, co
 | 
			
		|||
        const ImGuiID id = ImGui::GetID(search_str);
 | 
			
		||||
        ImVec2 search_size = ImVec2(size.x, ImGui::GetTextLineHeightWithSpacing() + style.ItemSpacing.y);
 | 
			
		||||
 | 
			
		||||
        if (!ImGui::IsAnyItemFocused() && !ImGui::IsAnyItemActive() && !ImGui::IsMouseClicked(0))
 | 
			
		||||
            ImGui::SetKeyboardFocusHere(0);
 | 
			
		||||
 | 
			
		||||
        // The press on Esc key invokes editing of InputText (removes last changes)
 | 
			
		||||
        // So we should save previous value...
 | 
			
		||||
        std::string str = search_str;
 | 
			
		||||
        ImGui::InputTextEx("", NULL, search_str, 20, search_size, 0, NULL, NULL);
 | 
			
		||||
        edited = ImGui::IsItemEdited();
 | 
			
		||||
 | 
			
		||||
        if (ImGui::IsItemDeactivated() && ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_Escape))) {
 | 
			
		||||
            // use 9999 to mark selection as a Esc key
 | 
			
		||||
            selected = 9999;
 | 
			
		||||
            // ... and when Esc key was pressed, than revert search_str value
 | 
			
		||||
            strcpy(search_str, str.c_str());
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        ImGui::BeginChildFrame(id, frame_bb.GetSize());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue