File tree Expand file tree Collapse file tree 2 files changed +45
-2
lines changed
Expand file tree Collapse file tree 2 files changed +45
-2
lines changed Original file line number Diff line number Diff line change 11using System . Collections . ObjectModel ;
2+ using System . Collections . Specialized ;
23using Avalonia . Controls ;
34using Avalonia . Controls . Metadata ;
45using Avalonia . Controls . Primitives ;
@@ -210,6 +211,41 @@ protected override void OnApplyTemplate(TemplateAppliedEventArgs e)
210211 handledEventsToo : true ) ;
211212 }
212213
214+ protected override void OnPropertyChanged ( AvaloniaPropertyChangedEventArgs change )
215+ {
216+ base . OnPropertyChanged ( change ) ;
217+
218+ if ( change . Property == ChatAttachmentItemsSourceProperty )
219+ {
220+ if ( change . OldValue is INotifyCollectionChanged oldValue )
221+ {
222+ oldValue . CollectionChanged -= HandleChatAttachmentItemsSourceChanged ;
223+ }
224+ if ( change . NewValue is INotifyCollectionChanged newValue )
225+ {
226+ newValue . CollectionChanged += HandleChatAttachmentItemsSourceChanged ;
227+ }
228+ }
229+ }
230+
231+ private void HandleChatAttachmentItemsSourceChanged ( object ? sender , NotifyCollectionChangedEventArgs e )
232+ {
233+ if ( _visualElementAttachmentOverlayWindow . IsValueCreated )
234+ {
235+ _visualElementAttachmentOverlayWindow . Value . UpdateForVisualElement ( null ) ; // Hide the overlay window when the attachment list changes.
236+ }
237+ }
238+
239+ protected override void OnUnloaded ( RoutedEventArgs e )
240+ {
241+ base . OnUnloaded ( e ) ;
242+
243+ if ( _visualElementAttachmentOverlayWindow . IsValueCreated )
244+ {
245+ _visualElementAttachmentOverlayWindow . Value . UpdateForVisualElement ( null ) ; // Hide the overlay window when the control is unloaded.
246+ }
247+ }
248+
213249 protected override void OnPointerPressed ( PointerPressedEventArgs e )
214250 {
215251 // Because this control is inherited from TextBox, it will receive pointer events and broke the MenuItem's pointer events.
Original file line number Diff line number Diff line change @@ -4,10 +4,11 @@ namespace Everywhere.Views;
44
55public class OverlayWindow : Window
66{
7- // todo: make this window don't cover the owner
7+ private readonly WindowBase ? _owner ;
8+
89 public OverlayWindow ( WindowBase ? owner = null )
910 {
10- Owner = owner ;
11+ _owner = owner ;
1112
1213 CanResize = false ;
1314 ShowInTaskbar = false ;
@@ -41,6 +42,12 @@ public void UpdateForVisualElement(IVisualElement? element)
4142 var scaling = DesktopScaling ;
4243 Width = boundingRectangle . Width / scaling ;
4344 Height = boundingRectangle . Height / scaling ;
45+
46+ if ( _owner is { Topmost : true } )
47+ {
48+ _owner . Topmost = false ;
49+ _owner . Topmost = true ;
50+ }
4451 }
4552 }
4653}
You can’t perform that action at this time.
0 commit comments