How to exit a HaxeUIApp application?

I’d like to have a “quit” menu option.

I can add a “quit” menu item, but I’m surprised to find that I can’t find a way to do the actual quitting in a cross-platform way. I can’t find an example where this is done, either.

The HaxeUIApp class inherits an exit method, but it seems to be empty.

What’s the idiomatic way to do this?

What backend?

Sys.exit(0) (for sys platforms)

“exiting” doesnt really mean anything for non-sys platforms, does it?

Well, no specific backend.

Calling sys.exit() would work if it’s available, but then requires a compile-time conditional to allow it to compile on non-sys backends.

It is also circumventing the UI, possibly making it shut down in an unpredictable way. I don’t know if I would be taking chances.

And if the back-end does not support sys, it might be necessary or useful to trigger something appropriate for that back end - perhaps closing a window, or something else, depending on the back end. The HaxeUIApp would ideally know the right thing to do for that, as it does the set-up.

So without any other clues, using sys.exit() seemed likely an option of last resort, to be used if there was no HaxeUI alternative. Noticing that there’s a HaxeUIApp, with an exit method, I was wondering if I was missing something. I guessed that HaxeUIApp.exit() was there do that by default, and on backends without sys.exit() that would be a no-op, or perhaps something else.

If not, that’s fine - I guess this means it’s safe and correct to implement something on top of HaxeUIApp which calls sys.exit() if available?

I thought i answered this, my bad

so i think the only place where haxeuiapp.exit does something haxeui-hxwidgets. That said, i think your suggestions above make sense… it wouldnt hurt to fill in empty (sys platform) backends with a Sys.exit (or any framework specific way)

Ill check it out when i get a moment.


1 Like