[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 (); initialize ();
init_pair (1, COLOR_WHITE, COLOR_BLUE); init_pair (1, COLOR_WHITE, COLOR_BLUE);
init_pair (2, COLOR_WHITE, COLOR_BLACK); 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); init_pair (4, COLOR_YELLOW, COLOR_RED);
screen = [TextContext screen]; screen = [TextContext screen];

View File

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

View File

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