Hi,
Is there a way to close a SimpleDialog, which was started with DoModal?
I've tried to call OnOK(), OnCancel() and EndDialog(dlg) but they were all undefined (nil).
I would like to close the modal dialog, after another button than the OK/Cancel button was clicked.
Is there a way to close a SimpleDialog
Moderators: Víctor Paredes, Belgarath, slowtiger
Re: Is there a way to close a SimpleDialog
To my knowledge the answer is no, but I wish the answer was yes.I would even like the option to close them from code in the main application.
Moho 14.3 » Win 11 Pro 64GB » NVIDIA GTX 1080ti 11GB
Moho 14.3 » Mac mini 2012 8GB » macOS 10.15 Catalina
Tube: SimplSam
Sam
Moho 14.3 » Mac mini 2012 8GB » macOS 10.15 Catalina
Tube: SimplSam
Sam
Re: Is there a way to close a SimpleDialog
Hi Sam,
That was my suspicion. I've now created a c++ lua module that allows to close the modal dialog using a workaround:
This needs to be done in a thread with a small delay, as the moho interface needs to have time to react, apparently.
That was my suspicion. I've now created a c++ lua module that allows to close the modal dialog using a workaround:
Code: Select all
extern "C" __declspec(dllexport) int closeMenuWindow(lua_State * L)
{
lua_lock(L);
const char* windowName = luaL_checkstring(L, -1);
lua_pushnil(L);
lua_unlock(L);
#ifdef _WIN32
std::thread([]() {
std::this_thread::sleep_for(std::chrono::milliseconds(100));
HWND hwnd = FindWindowA("LM_Wnd", windowName);
if (!hwnd) {
return 1;
}
bool status = PostMessageA(hwnd, WM_KEYDOWN, VK_RETURN, 0);
if (!status) {
DWORD lastError = GetLastError();
int i = 0;
}
}).detach();
#endif
return 1;
}
Re: Is there a way to close a SimpleDialog
That's a neat work-around. I also have an Elgato Stream Deck keypad which I use to initiate script and/or key-press sequences which are used to control some features of Moho.
Moho 14.3 » Win 11 Pro 64GB » NVIDIA GTX 1080ti 11GB
Moho 14.3 » Mac mini 2012 8GB » macOS 10.15 Catalina
Tube: SimplSam
Sam
Moho 14.3 » Mac mini 2012 8GB » macOS 10.15 Catalina
Tube: SimplSam
Sam
-
- Posts: 69
- Joined: Thu Jan 24, 2019 3:52 am
Re: Is there a way to close a SimpleDialog
To close a Domodal from another button you simply create a button in the dialog like this:mminsel wrote: ↑Tue May 02, 2023 10:09 pm Hi,
Is there a way to close a SimpleDialog, which was started with DoModal?
I've tried to call OnOK(), OnCancel() and EndDialog(dlg) but they were all undefined (nil).
I would like to close the modal dialog, after another button than the OK/Cancel button was clicked.
Code: Select all
d.boton = LM.GUI.Button("Close dialog", LM.GUI.MSG_CANCEL)
l:AddChild(d.boton)
- MehdiZangenehBar
- Posts: 114
- Joined: Wed Feb 07, 2024 7:17 pm
- Contact:
Re: Is there a way to close a SimpleDialog
Any chance we can have access to that extension?mminsel wrote: ↑Fri May 05, 2023 11:02 am Hi Sam,
That was my suspicion. I've now created a c++ lua module that allows to close the modal dialog using a workaround:
This needs to be done in a thread with a small delay, as the moho interface needs to have time to react, apparently.Code: Select all
extern "C" __declspec(dllexport) int closeMenuWindow(lua_State * L) { lua_lock(L); const char* windowName = luaL_checkstring(L, -1); lua_pushnil(L); lua_unlock(L); #ifdef _WIN32 std::thread([]() { std::this_thread::sleep_for(std::chrono::milliseconds(100)); HWND hwnd = FindWindowA("LM_Wnd", windowName); if (!hwnd) { return 1; } bool status = PostMessageA(hwnd, WM_KEYDOWN, VK_RETURN, 0); if (!status) { DWORD lastError = GetLastError(); int i = 0; } }).detach(); #endif return 1; }