Problem when closing a window programmatically

Perhaps my understanding isn’t correct, but after reading the Window section in the docs I would expect calling the window.Close() method should result in the following.

  • If WindowCloseAction is None
    • Window stays open, Closing and Closed events are not fired
  • If WindowCloseAction is Hide
    • Windows hides, Closing and Closed events are not fired
  • If WindowCloseAction is Disposed
    • Windows is disposed, Closing and Closed events are fired

But this isn’t quite what is happening. I have tried this on Windows in Visual Studio and MacOS (intel) in Rider with the following results.

  • When calling windowClose():
    • If WindowCloseAction is None
      • Works as expected
    • If WindowCloseAction is Hide
      • Closing event is fired, but otherwise works as expected
    • If WindowCloseAction is Disposed
      • Window hides but is not disposed
      • Closed event is not fired but Closing event is fired
  • When Clicking on close box in corner instead of calling Close()
    • On Windows: Closing event is not fired, though Closed is fired and window is disposed
    • On MacOS: Works as expected, Closing and Closed are fired and window is disposed

Thank you for your message. I will test the behavior of the Close method and let you know the results as soon as possible.

When WindowCloseAction is set to Hide, the Closing event is fired, and this is the expected behavior. This event allows you to perform checks to determine whether the window close operation should be allowed. I will review the documentation and add some notes there.

I confirm that the window is not disposed when Close is called with WindowCloseAction.Dispose on the MSW platform. This is a bug, and we will address it in upcoming builds. Until it is fixed, you can call SendDispose to close and dispose of the window.

When clicking on close box in corner, Closing/Closed events are fired on MSW. There is a Window related demo in Samples/Window Properties. It logs Closing/Closed events. You can check there and see log items when close box in corner is clicked.

Thank you for looking into this. By the way, AlterNET UI is truly amazing!!!

I think we fixed issues related to Window.Close method in 1.1.0. Please try it and let me know whether it is ok now.

It seems to be working fine on Windows. However, Alternet-UI 1.10 projects do not run on MacOS (Intel). There is a System.EntryPointNotFoundException in Main() when creating a new Application instance.

System.EntryPointNotFoundException: Unable to find an entry point named ‘Font_CreateFontRef_’ in shared library ‘Alternet.UI.Pal.dll’.
at Alternet.UI.Native.Font.NativeApi.Font_CreateFontRef_(GenericFontFamily genericFamily, NativeStringSpan& familyName, Single emSizeInPoints, FontStyle style)
at Alternet.UI.Native.Font.CreateFontRef(GenericFontFamily genericFamily, NativeStringSpan familyName, Single emSizeInPoints, FontStyle style)
at Alternet.UI.WxControlHandler.<>c__DisplayClass41_1.b__0(NativeStringSpan span)
at Alternet.UI.StringUtils.<>c__DisplayClass32_0.b__0(IntPtr ptr, Int32 length)
at Alternet.Skia.SkiaHelper.InvokeWithUTF8Span(ReadOnlySpan1 input, Action2 action)
at Alternet.UI.StringUtils.InvokeWithNativeText(ReadOnlySpan1 text, Action1 callback)
at Alternet.UI.WxControlHandler.GetFontRef(Font value)
at Alternet.Drawing.WxFontFactoryHandler.SetDefaultFont(Font value)
at Alternet.UI.AbstractControl.set_DefaultFont(Font value)
at Alternet.UI.Window.UpdateDefaultFont()
at Alternet.UI.App..ctor(IApplicationHandler handler)
at Alternet.UI.Application..ctor(IApplicationHandler handler)
at Alternet.UI.Application..ctor()
at AlternetUIApp2.Program.Main(String args) in ‘path to project’

Alternet.UI 1.1.0 build is only for arm cpu. I think we will include Intel version in the new release.