mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-10-30 20:21:12 -06:00 
			
		
		
		
	OSX and Linux specific: Fixed preset selection
This commit is contained in:
		
							parent
							
								
									3e54c0b775
								
							
						
					
					
						commit
						9305535039
					
				
					 2 changed files with 23 additions and 6 deletions
				
			
		|  | @ -861,9 +861,15 @@ void Choice::BUILD() { | ||||||
|     temp->SetItemBitmap(0, empty_bmp); |     temp->SetItemBitmap(0, empty_bmp); | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
| // 	temp->Bind(wxEVT_TEXT, ([this](wxCommandEvent e) { on_change_field(); }), temp->GetId());
 |  | ||||||
|     temp->Bind(wxEVT_COMBOBOX_DROPDOWN, [this](wxCommandEvent&) { m_is_dropped = true;  }); |     temp->Bind(wxEVT_COMBOBOX_DROPDOWN, [this](wxCommandEvent&) { m_is_dropped = true;  }); | ||||||
|     temp->Bind(wxEVT_COMBOBOX_CLOSEUP,  [this](wxCommandEvent&) { m_is_dropped = false; }); |     temp->Bind(wxEVT_COMBOBOX_CLOSEUP,  [this](wxCommandEvent& evt) { | ||||||
|  | 		// EVT_COMBOBOX_CLOSEUP is called after EVT_COMBOBOX on Windows
 | ||||||
|  | 		// so, always set m_suppress_change to "true"
 | ||||||
|  | #ifndef __WXMSW__  | ||||||
|  | 		if (m_last_selected == evt.GetSelection()) | ||||||
|  | #endif //__WXMSW__
 | ||||||
|  |             m_is_dropped = false; | ||||||
|  |     }); | ||||||
| 
 | 
 | ||||||
|     temp->Bind(wxEVT_COMBOBOX, ([this, temp](wxCommandEvent evt) { |     temp->Bind(wxEVT_COMBOBOX, ([this, temp](wxCommandEvent evt) { | ||||||
|         if (m_suppress_scroll) { |         if (m_suppress_scroll) { | ||||||
|  | @ -874,6 +880,7 @@ void Choice::BUILD() { | ||||||
|             m_last_selected = evt.GetSelection(); |             m_last_selected = evt.GetSelection(); | ||||||
|         } |         } | ||||||
|         on_change_field(); |         on_change_field(); | ||||||
|  |         m_is_dropped = false; | ||||||
|     }), temp->GetId()); |     }), temp->GetId()); | ||||||
| 
 | 
 | ||||||
|     if (m_is_editable) { |     if (m_is_editable) { | ||||||
|  | @ -998,13 +1005,14 @@ void Choice::set_value(const boost::any& value, bool change_event) | ||||||
| 		else | 		else | ||||||
| 			text_value = boost::any_cast<wxString>(value); | 			text_value = boost::any_cast<wxString>(value); | ||||||
|         size_t idx = 0; |         size_t idx = 0; | ||||||
| 		for (auto el : m_opt.enum_values) |         const std::vector<std::string>& enums = m_opt.enum_values.empty() ? m_opt.enum_labels : m_opt.enum_values; | ||||||
|  | 		for (auto el : enums) | ||||||
| 		{ | 		{ | ||||||
| 			if (el == text_value) | 			if (el == text_value) | ||||||
| 				break; | 				break; | ||||||
| 			++idx; | 			++idx; | ||||||
| 		} | 		} | ||||||
|         if (idx == m_opt.enum_values.size()) { |         if (idx == enums.size()) { | ||||||
|             // For editable Combobox under OSX is needed to set selection to -1 explicitly,
 |             // For editable Combobox under OSX is needed to set selection to -1 explicitly,
 | ||||||
|             // otherwise selection doesn't be changed
 |             // otherwise selection doesn't be changed
 | ||||||
|             field->SetSelection(-1); |             field->SetSelection(-1); | ||||||
|  | @ -1012,7 +1020,7 @@ void Choice::set_value(const boost::any& value, bool change_event) | ||||||
|         } |         } | ||||||
|         else |         else | ||||||
| 			field->SetSelection(idx); | 			field->SetSelection(idx); | ||||||
| 		if (m_suppress_scroll && idx < m_opt.enum_values.size()) m_last_selected = idx; | 		if (m_suppress_scroll && idx < enums.size()) m_last_selected = idx; | ||||||
| 		break; | 		break; | ||||||
| 	} | 	} | ||||||
| 	case coEnum: { | 	case coEnum: { | ||||||
|  |  | ||||||
|  | @ -104,7 +104,14 @@ PresetComboBox::PresetComboBox(wxWindow* parent, Preset::Type preset_type, const | ||||||
|     // parameters for an icon's drawing
 |     // parameters for an icon's drawing
 | ||||||
|     fill_width_height(); |     fill_width_height(); | ||||||
|     Bind(wxEVT_COMBOBOX_DROPDOWN, [this](wxCommandEvent& evt) { m_suppress_change = false; }); |     Bind(wxEVT_COMBOBOX_DROPDOWN, [this](wxCommandEvent& evt) { m_suppress_change = false; }); | ||||||
|     Bind(wxEVT_COMBOBOX_CLOSEUP,  [this](wxCommandEvent& evt) { m_suppress_change = true ; }); |     Bind(wxEVT_COMBOBOX_CLOSEUP,  [this](wxCommandEvent& evt) { | ||||||
|  |         // EVT_COMBOBOX_CLOSEUP is called after EVT_COMBOBOX on Windows
 | ||||||
|  |         // so, always set m_suppress_change to "true"
 | ||||||
|  | #ifndef __WXMSW__  | ||||||
|  |         if (m_last_selected == evt.GetSelection()) | ||||||
|  | #endif //__WXMSW__
 | ||||||
|  |             m_suppress_change = true; | ||||||
|  |     }); | ||||||
| 
 | 
 | ||||||
|     Bind(wxEVT_COMBOBOX, [this](wxCommandEvent& evt) { |     Bind(wxEVT_COMBOBOX, [this](wxCommandEvent& evt) { | ||||||
|         // see https://github.com/prusa3d/PrusaSlicer/issues/3889
 |         // see https://github.com/prusa3d/PrusaSlicer/issues/3889
 | ||||||
|  | @ -572,6 +579,7 @@ PlaterPresetComboBox::PlaterPresetComboBox(wxWindow *parent, Preset::Type preset | ||||||
|         } else { |         } else { | ||||||
|             evt.StopPropagation(); |             evt.StopPropagation(); | ||||||
|         } |         } | ||||||
|  |         m_suppress_change = true; | ||||||
|     }); |     }); | ||||||
| 
 | 
 | ||||||
|     if (m_type == Preset::TYPE_FILAMENT) |     if (m_type == Preset::TYPE_FILAMENT) | ||||||
|  | @ -911,6 +919,7 @@ TabPresetComboBox::TabPresetComboBox(wxWindow* parent, Preset::Type preset_type) | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         evt.StopPropagation(); |         evt.StopPropagation(); | ||||||
|  |         m_suppress_change = true; | ||||||
|     }); |     }); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 YuSanka
						YuSanka