mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-06-06 06:34:35 +00:00
Move the popup windows to follow the mouse
This commit is contained in:
parent
7ea6ef4076
commit
e794057d9f
1 changed files with 12 additions and 1 deletions
|
|
@ -152,6 +152,17 @@ static void loop()
|
|||
SDL_zero(tooltip);
|
||||
}
|
||||
tooltip_timer = SDL_GetTicks() + TOOLTIP_DELAY;
|
||||
|
||||
if (num_menus > 0) {
|
||||
int parent_x = 0, parent_y = 0;
|
||||
int x = event.motion.x;
|
||||
int y = event.motion.y;
|
||||
|
||||
SDL_GetWindowPosition(menus[0].parent, &parent_x, &parent_y);
|
||||
x -= parent_x;
|
||||
y -= parent_y;
|
||||
SDL_SetWindowPosition(menus[0].win, x, y);
|
||||
}
|
||||
} else if (event.type == SDL_EVENT_MOUSE_BUTTON_DOWN) {
|
||||
/* Left click closes the popup menus */
|
||||
if (event.button.button == SDL_BUTTON_LEFT) {
|
||||
|
|
@ -245,4 +256,4 @@ int main(int argc, char *argv[])
|
|||
quit(0);
|
||||
/* keep the compiler happy ... */
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue