description of the problem
I have a Delphi component. To set a value, you can click and drag.
However, when you reach the edge of the screen, you cannot move on. Then you need to go back to the component and drag it further, which is not very convenient.
preferred solution
I would like the mouse cursor to wrap around the screen if you reach the edge to continue scrolling the value. 3dsmax makes extensive use of this type of GUI control, and I like how it works.
Alternatively, it would be nice for me if the cursor went out of the screen, but continued to send X / Y coordinates that are outside the borders of the screen.
that i still
I know that I can get / set the current mouse position using Mouse.CursorPos and that screen sizes are available through Screen.Width and Screen.Height.
The code below wraps a mousetrap around what I want.
procedure TFormXXXX.YYYYMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
var
LX, LY: Integer;
begin
LX := Mouse.CursorPos.X;
if LX < 1 then
LX := Screen.Width - 1
else
if LX>Screen.Width -2 then
LX := 0;
LY := Mouse.CursorPos.Y;
if LY < 1 then
LY := Screen.Height - 1
else
if LY>Screen.Height -2 then
LY := 0;
Mouse.CursorPos := Point(LX, LY);
end;
There is still a problem that I have to "manually" track the wrappers to get the correct offset from the starting point, but I will find a way to solve this problem.
I just don't know if this is suitable for this. Maybe someone has some experience or wise words to say this ...
main question
Is there a proven general approach to this? Do windows have something like this?
some doubts that I have
- How will this behave when there are multiple monitors?
- , (VNC?).. 0 ?
- , , ?
- ? , , .