From db65fd6e834aabef3eeda493042ec5e33772fcd4 Mon Sep 17 00:00:00 2001 From: "chunmao.guo" Date: Wed, 8 Mar 2023 15:37:46 +0800 Subject: [PATCH] FIX: [STUDIO-1940] hide edit ctrl on scroll in ObjectList Change-Id: I9936ecff241d468f14e3dda0c12e4458cad8c237 --- src/slic3r/GUI/GUI_ObjectList.cpp | 6 +++++- src/slic3r/Utils/MacDarkMode.mm | 23 ++++++++++++++++++++++- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/src/slic3r/GUI/GUI_ObjectList.cpp b/src/slic3r/GUI/GUI_ObjectList.cpp index 104dc4000..587d4dc33 100644 --- a/src/slic3r/GUI/GUI_ObjectList.cpp +++ b/src/slic3r/GUI/GUI_ObjectList.cpp @@ -265,7 +265,8 @@ ObjectList::ObjectList(wxWindow* parent) : this->CallAfter([this]() { ensure_current_item_visible(); }); #endif e.Skip(); - })); + })); + } ObjectList::~ObjectList() @@ -4925,6 +4926,9 @@ void ObjectList::OnEditingStarted(wxDataViewEvent &event) if (col == colName) // TODO: for colName editing, disable shortcuts SetAcceleratorTable(wxNullAcceleratorTable); } +#ifdef __WXOSX__ + SetCustomRendererPtr(dynamic_cast(renderer)); +#endif #endif //__WXMSW__ } diff --git a/src/slic3r/Utils/MacDarkMode.mm b/src/slic3r/Utils/MacDarkMode.mm index 10248fd0f..e539053c1 100644 --- a/src/slic3r/Utils/MacDarkMode.mm +++ b/src/slic3r/Utils/MacDarkMode.mm @@ -208,7 +208,7 @@ void openFolderForFile(wxString const & file) @end -/* edit column for wxTableView */ +/* edit column for wxCocoaOutlineView */ #include #include @@ -216,8 +216,20 @@ void openFolderForFile(wxString const & file) @implementation wxCocoaOutlineView (Edit) +bool addObserver = false; + - (BOOL)outlineView: (NSOutlineView*) view shouldEditTableColumn:(nullable NSTableColumn *)tableColumn item:(nonnull id)item { + NSClipView * clipView = [[self enclosingScrollView] contentView]; + if (!addObserver) { + addObserver = true; + clipView.postsBoundsChangedNotifications = YES; + [[NSNotificationCenter defaultCenter] addObserver:self + selector:@selector(synchronizedViewContentBoundsDidChange:) + name:NSViewBoundsDidChangeNotification + object:clipView]; + } + wxDataViewColumn* const col((wxDataViewColumn *)[tableColumn getColumnPointer]); wxDataViewItem item2([static_cast(item) pointer]); @@ -227,9 +239,18 @@ void openFolderForFile(wxString const & file) dvc->GetEventHandler()->ProcessEvent( event ); if( !event.IsAllowed() ) return NO; + return YES; } +- (void)synchronizedViewContentBoundsDidChange:(NSNotification *)notification +{ + wxDataViewCtrl* const dvc = implementation->GetDataViewCtrl(); + wxDataViewCustomRenderer * r = dvc->GetCustomRendererPtr(); + if (r) + r->FinishEditing(); +} + @end /* Font for wxTextCtrl */