airsdk / Adobe-Runtime-Support

Report, track and discuss issues in Adobe AIR. Monitored by Adobe - and HARMAN - and maintained by the AIR community.
201 stars 11 forks source link

[Feature Request] [Windows][macOS] NativeMenu close method #191

Open itlancer opened 4 years ago

itlancer commented 4 years ago

Feature Description

NativeMenu::close() method should be implemented to close displayed NativeMenu or ContextMenu programmatically. Right now there is no way to hide such menus (after it was showed) by user inactivity timeout for example. But it must have for kiosks application or other similar cases.

Known Workarounds

write native extension

ajwfrost commented 5 months ago

Hi

I'm not actually sure this is possible ... at least on Windows, we are using native Win32 menu items, and once these are displayed it's up to the OS to get rid of them. We've just played around with removing the menu from the NativeWindow, or removing menu items whilst they're being displayed, but that doesn't seem to help..

Seems like the only option here would be to use a pseudo-menu system that's actually rendered using Feathers or similar and that is then part of the AIR-managed display list.

thanks

itlancer commented 5 months ago

@ajwfrost What about sending WM_CANCELMODE message? https://stackoverflow.com/questions/19226173/how-to-close-a-context-menu-after-a-timeout

ajwfrost commented 5 months ago

WM_CANCELMODE does close an active menu, but has other side-effects - for example if you are resizing a window, this event causes that process to be cancelled. So it's linked to also knowing when/whether the menu has been cancelled manually by the user (per #192). If we can determine whether the menu is visible or not, we should be able to do this...

itlancer commented 5 months ago

If we can determine whether the menu is visible or not, we should be able to do this...

Thank you very much.

WM_CANCELMODE does close an active menu, but has other side-effects - for example if you are resizing a window, this event causes that process to be cancelled

Seems that's what we need for another feature request https://github.com/airsdk/Adobe-Runtime-Support/issues/2534

2jfw commented 5 months ago

Would it be possible to dispatch a (Windows) mouse down event (maybe on 0|0 or outside of the screen) or an Windows escape key press to close the menu? (possible dirty workaround 😅)