Tcl/TK will support multiple threading but it would make the implementation of this very messy. Tcl/TK waits on GetMessage so you need to wedge in there (using the standard Tcl/Tk notification and event sources is useless in this case).
We have solved the problem like this - I hope this is useful to someone. (this is for Windows Tcl/Tk only)
Code: Select all
WNDPROC oldWndProc; // old WindowProc function
// the new hook function that's wedged into the window event handler
LRESULT CALLBACK HookWndProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
{
check_for_space_mouse_event(msg, wp, lp); // see if it's a space mouse event
LRESULT lr = CallWindowProc(oldWndProc, hwnd, msg, wp, lp); // call the old event handler
return(lr);
}
if (space_mouse_init())
{
Tk_Window tkwin = Tk_NameToWindow(interp, ".", Tk_MainWindow(interp));
Window win = Tk_WindowId(tkwin);
HWND hwnd = Tk_GetHWND(win);
// set the hook proc and record the old
oldWndProc = (WNDPROC)SetWindowLong(hwnd, GWL_WNDPROC, (DWORD)HookWndProc);
}
This will be in our software soon. If you would like to test it before release please contact me - see
www.inivis.com for more details on AC3D (3D modelling software)
Andy