[qwaq] Implement mouse grabbing

Button will need it for dragging.
This commit is contained in:
Bill Currie 2020-03-19 19:00:03 +09:00
parent 2c20a031e4
commit 95d20d67c7
3 changed files with 8 additions and 5 deletions

View File

@ -40,7 +40,7 @@ arp_end (void)
initialize ();
init_pair (1, COLOR_WHITE, COLOR_BLUE);
init_pair (2, COLOR_WHITE, COLOR_BLACK);
init_pair (3, COLOR_WHITE, COLOR_GREEN);
init_pair (3, COLOR_BLACK, COLOR_GREEN);
init_pair (4, COLOR_YELLOW, COLOR_RED);
screen = [TextContext screen];

View File

@ -38,13 +38,15 @@
switch ((qwaq_mouse_event) (event.what & qe_mouse)) {
case qe_mousedown:
pressed = 1;
[self redraw];
action = onPress;
[self grabMouse];
[self redraw];
break;
case qe_mouseup:
pressed = 0;
[self redraw];
action = onRelease;
[self releaseMouse];
[self redraw];
break;
case qe_mouseclick:
action = onClick;

View File

@ -27,6 +27,7 @@
-insert: (View *) view
{
[views addObject: view];
[view setOwner: self];
[view setContext: context];
return self;
}
@ -135,8 +136,8 @@ find_mouse_view(Group *group, Point pos)
-(void) releaseMouse
{
mouse_grabbed = mouse_within;
[owner grabMouse];
mouse_grabbed = nil;
[owner releaseMouse];
}
@end