|
|
@ -8,6 +8,8 @@ namespace Avalonia.Native |
|
|
class PopupImpl : WindowBaseImpl, IPopupImpl |
|
|
class PopupImpl : WindowBaseImpl, IPopupImpl |
|
|
{ |
|
|
{ |
|
|
private readonly ITopLevelImpl _parent; |
|
|
private readonly ITopLevelImpl _parent; |
|
|
|
|
|
private readonly IAvnPopup _native; |
|
|
|
|
|
private readonly AvaloniaNativeTextInputMethod _inputMethod; |
|
|
|
|
|
|
|
|
public PopupImpl(IAvaloniaNativeFactory factory, |
|
|
public PopupImpl(IAvaloniaNativeFactory factory, |
|
|
ITopLevelImpl parent) : base(factory) |
|
|
ITopLevelImpl parent) : base(factory) |
|
|
@ -16,7 +18,7 @@ namespace Avalonia.Native |
|
|
|
|
|
|
|
|
using (var e = new PopupEvents(this)) |
|
|
using (var e = new PopupEvents(this)) |
|
|
{ |
|
|
{ |
|
|
Init(new MacOSTopLevelHandle(factory.CreatePopup(e)), factory.CreateScreens()); |
|
|
Init(new MacOSTopLevelHandle(_native = factory.CreatePopup(e)), factory.CreateScreens()); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
PopupPositioner = new ManagedPopupPositioner(new ManagedPopupPositionerPopupImplHelper(parent, MoveResize)); |
|
|
PopupPositioner = new ManagedPopupPositioner(new ManagedPopupPositionerPopupImplHelper(parent, MoveResize)); |
|
|
@ -26,15 +28,10 @@ namespace Avalonia.Native |
|
|
parent = popupImpl._parent; |
|
|
parent = popupImpl._parent; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (parent is WindowBaseImpl windowBaseImpl) |
|
|
|
|
|
{ |
|
|
|
|
|
Native!.SetParent(windowBaseImpl.Native); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//Use the parent's input context to process events
|
|
|
//Use the parent's input context to process events
|
|
|
if (parent is TopLevelImpl topLevelImpl) |
|
|
if (parent is TopLevelImpl topLevelImpl) |
|
|
{ |
|
|
{ |
|
|
InputMethod = topLevelImpl.InputMethod; |
|
|
_inputMethod = topLevelImpl.InputMethod; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -43,13 +40,6 @@ namespace Avalonia.Native |
|
|
base.Init(handle, screens); |
|
|
base.Init(handle, screens); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public override void Dispose() |
|
|
|
|
|
{ |
|
|
|
|
|
Native!.SetParent(null); |
|
|
|
|
|
|
|
|
|
|
|
base.Dispose(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void MoveResize(PixelPoint position, Size size, double scaling) |
|
|
private void MoveResize(PixelPoint position, Size size, double scaling) |
|
|
{ |
|
|
{ |
|
|
Position = position; |
|
|
Position = position; |
|
|
@ -81,6 +71,16 @@ namespace Avalonia.Native |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public override void Show(bool activate, bool isDialog) |
|
|
|
|
|
{ |
|
|
|
|
|
var parent = _parent; |
|
|
|
|
|
while (parent is PopupImpl p) |
|
|
|
|
|
parent = p._parent; |
|
|
|
|
|
if (parent is WindowImpl w) |
|
|
|
|
|
w.Native.TakeFocusFromChildren(); |
|
|
|
|
|
base.Show(false, isDialog); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
public override IPopupImpl CreatePopup() => new PopupImpl(Factory, this); |
|
|
public override IPopupImpl CreatePopup() => new PopupImpl(Factory, this); |
|
|
|
|
|
|
|
|
public void SetWindowManagerAddShadowHint(bool enabled) |
|
|
public void SetWindowManagerAddShadowHint(bool enabled) |
|
|
|