mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-23 04:42:32 +00:00
[qwaq] Implement mouse enter/leave events
This commit is contained in:
parent
3e9977c272
commit
23e6b49845
4 changed files with 54 additions and 3 deletions
|
@ -11,6 +11,8 @@
|
|||
@interface Group : Object
|
||||
{
|
||||
Array *views;
|
||||
View *mouse_grabbed;
|
||||
View *mouse_within;
|
||||
int focused;
|
||||
id<TextContext> context;
|
||||
}
|
||||
|
|
|
@ -65,6 +65,18 @@ not_dont_draw (id aView, void *aGroup)
|
|||
return self;
|
||||
}
|
||||
|
||||
static View *
|
||||
find_mouse_view(Group *group, Point pos)
|
||||
{
|
||||
for (int i = [group.views count]; i--; ) {
|
||||
View *v = [group.views objectAtIndex: i];
|
||||
if ([v containsPoint: pos]) {
|
||||
return v;
|
||||
}
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
|
||||
-handleEvent: (qwaq_event_t *) event
|
||||
{
|
||||
if (event.what & qe_focused) {
|
||||
|
@ -72,6 +84,24 @@ not_dont_draw (id aView, void *aGroup)
|
|||
[[views objectAtIndex:focused] handleEvent: event];
|
||||
}
|
||||
} else if (event.what & qe_positional) {
|
||||
Point pos = {event.mouse.x, event.mouse.y};
|
||||
if (mouse_grabbed) {
|
||||
[mouse_grabbed handleEvent: event];
|
||||
} else {
|
||||
if (mouse_within && ![mouse_within containsPoint: pos]) {
|
||||
[mouse_within onMouseLeave: pos];
|
||||
mouse_within = nil;
|
||||
}
|
||||
if (!mouse_within) {
|
||||
mouse_within = find_mouse_view (self, pos);
|
||||
if (mouse_within) {
|
||||
[mouse_within onMouseEnter: pos];
|
||||
}
|
||||
}
|
||||
if (mouse_within) {
|
||||
[mouse_within handleEvent: event];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// broadcast
|
||||
[views makeObjectsPerformSelector: @selector(draw) withObject: event];
|
||||
|
|
|
@ -60,7 +60,9 @@ enum {
|
|||
|
||||
-setOwner: (Group *) owner;
|
||||
|
||||
-(struct Rect_s *)rect;
|
||||
-(Rect)rect;
|
||||
|
||||
-(int) containsPoint: (Point) point;
|
||||
|
||||
-(int) options;
|
||||
|
||||
|
@ -69,6 +71,9 @@ enum {
|
|||
-redraw;
|
||||
-handleEvent: (qwaq_event_t *) event;
|
||||
|
||||
- (void) onMouseEnter: (Point) pos;
|
||||
- (void) onMouseLeave: (Point) pos;
|
||||
|
||||
|
||||
- (void) refresh;
|
||||
- (void) mvprintf: (Point) pos, string fmt, ...;
|
||||
|
|
|
@ -95,9 +95,14 @@ updateScreenCursor (View *view)
|
|||
return self;
|
||||
}
|
||||
|
||||
- (Rect *) rect
|
||||
- (Rect) rect
|
||||
{
|
||||
return ▭
|
||||
return rect;
|
||||
}
|
||||
|
||||
-(int) containsPoint: (Point) point
|
||||
{
|
||||
return rectContainsPoint (rect, point);
|
||||
}
|
||||
|
||||
- (void) forward: (SEL) sel : (@va_list) args
|
||||
|
@ -144,4 +149,13 @@ updateScreenCursor (View *view)
|
|||
return self;
|
||||
}
|
||||
|
||||
- (void) onMouseEnter: (Point) pos
|
||||
{
|
||||
}
|
||||
|
||||
- (void) onMouseLeave: (Point) pos
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
|
|
Loading…
Reference in a new issue