问题
I have made an Excel add-in, which pops up a window either by window.open
or Dialog API.
I just tested it in Excel for Mac: when the window is opened, it seems that we can NOT put the focus back to Excel or the add-in taskpane; we have to close the window before choosing Excel or the add-in taskpane.
Does anyone know if there is a way to enable switching focus between popup window and Excel?
回答1:
The dialog window is a modal in nature that forces the user to interact with it before they can go back to using the parent add-in/Office host. For interaction that requires back-n-forth with Excel, task-pane is the right place for UI.
回答2:
The dialog API is meant to always show the dialog on top of other items. In terms of modality, you are correct that in Windows the dialog allows you to still interact with the spreadsheet while in other platforms, like Mac or Online is fully modal (cannot switch back to the spreadsheet). My recommendation is to design your add-in accounting for multi-platform so assume the dialog is modal in all platforms. As Sudhi recommends in his response, if your interaction requires the user to use the add-in and the spreadsheet back and forth, using a pane is a better model.
来源:https://stackoverflow.com/questions/44735768/cannot-switch-between-popup-window-and-excel-for-mac