e.g. Alt + Drag to pull attributes, BB will lose respond... This is my fixup to this problem.
Code: Select all
VAR idle:BOOLEAN;
PROCEDURE (rd: Rider) Input* (OUT x, y: INTEGER; OUT modifiers: SET; OUT isDown: BOOLEAN);
VAR msg: WinApi.MSG; wnd, mw: WinApi.HANDLE; pt: WinApi.POINT; res: INTEGER; set: SET;
BEGIN
wnd := rd.port.wnd;
mw := WinApi.GetCapture(); idle:=TRUE;
(*res := WinApi.UpdateWindow(wnd);*) (* optional,seems to have no side effects*)
IF WinApi.PeekMessageW(msg, mw, WinApi.WM_MOUSEFIRST, WinApi.WM_MOUSELAST, 1) # 0 THEN
mx := (msg.lParam + 32768) MOD 65536 - 32768;
my := msg.lParam DIV 65536;
IF (mw # 0) & (wnd # mw) THEN
pt.x := mx; pt.y := my; res := WinApi.ClientToScreen(mw, pt);
res := WinApi.ScreenToClient(wnd, pt);
mx := pt.x;
my := pt.y
END;
mb := {};
set := BITS(msg.wParam);
IF WinApi.MK_LBUTTON * set # {} THEN INCL(mb, left) END;
IF WinApi.MK_MBUTTON * set # {} THEN INCL(mb, middle) END;
IF WinApi.MK_RBUTTON * set # {} THEN INCL(mb, right) END;
IF WinApi.MK_CONTROL * set # {} THEN INCL(mb, ctrl) END;
IF WinApi.MK_SHIFT * set # {} THEN INCL(mb, shift) END;
IF WinApi.GetAsyncKeyState(12H) < 0 THEN INCL(mb, alt) END;
ELSIF (WinApi.PeekMessageW(msg, 0, WinApi.WM_TIMER, WinApi.WM_TIMER, 1) # 0) THEN
idle:=FALSE;
res := WinApi.DispatchMessageW(msg)
END;
IF WinApi.GetSystemMetrics(WinApi.SM_SWAPBUTTON) # 0 THEN
IF WinApi.GetAsyncKeyState(WinApi.VK_LBUTTON(*1*)) >= 0 THEN EXCL(mb, right) END;
IF WinApi.GetAsyncKeyState(WinApi.VK_RBUTTON(*2*)) >= 0 THEN EXCL(mb, left) END
ELSE
IF WinApi.GetAsyncKeyState(WinApi.VK_LBUTTON(*1*)) >= 0 THEN EXCL(mb, left) END;
IF WinApi.GetAsyncKeyState(WinApi.VK_RBUTTON(*2*)) >= 0 THEN EXCL(mb, right) END
END;
IF WinApi.GetAsyncKeyState(WinApi.VK_MBUTTON(*4*)) >= 0 THEN EXCL(mb, middle) END;
IF WinApi.GetAsyncKeyState(WinApi.VK_SHIFT) < 0 THEN mb := mb + {shift, extend} ELSE mb := mb - {shift, extend} END;
IF WinApi.GetAsyncKeyState(WinApi.VK_CONTROL) < 0 THEN mb := mb + {ctrl, modify} ELSE mb := mb - {ctrl, modify}END;
IF WinApi.GetAsyncKeyState(WinApi.VK_MENU) < 0 THEN INCL(mb, alt) ELSE EXCL(mb, alt) END;
x := mx; y := my; modifiers := mb; isDown := mb * {left, middle, right} # {};
IF idle & isDown THEN WinApi.Sleep(1);END;
END Input;