mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-10 23:32:09 +00:00
[qwaq] Offset event mouse coordinates
Each level of the object hierarchy has its own offset relative to the level above, but mouse coordinates are absolute.
This commit is contained in:
parent
28a9e041e6
commit
cce6837fe8
2 changed files with 9 additions and 0 deletions
|
@ -23,6 +23,7 @@
|
|||
|
||||
-draw
|
||||
{
|
||||
[super draw];
|
||||
[textContext blitFromBuffer: icon[pressed]
|
||||
to: pos
|
||||
from: [icon[pressed] rect]];
|
||||
|
|
|
@ -94,6 +94,12 @@ find_mouse_view(Group *group, Point pos)
|
|||
[[views objectAtIndex:focused] handleEvent: event];
|
||||
}
|
||||
} else if (event.what & qe_positional) {
|
||||
Point origin = {};
|
||||
if (owner) {
|
||||
origin = [owner origin];
|
||||
}
|
||||
event.mouse.x -= origin.x;
|
||||
event.mouse.y -= origin.y;
|
||||
Point pos = {event.mouse.x, event.mouse.y};
|
||||
if (mouse_grabbed) {
|
||||
[mouse_grabbed handleEvent: event];
|
||||
|
@ -112,6 +118,8 @@ find_mouse_view(Group *group, Point pos)
|
|||
[mouse_within handleEvent: event];
|
||||
}
|
||||
}
|
||||
event.mouse.x += origin.x;
|
||||
event.mouse.y += origin.y;
|
||||
} else {
|
||||
// broadcast
|
||||
[views makeObjectsPerformSelector: @selector(draw) withObject: event];
|
||||
|
|
Loading…
Reference in a new issue