improve device selection
This commit is contained in:
parent
bdfaeea0d0
commit
c295b13018
|
@ -26,10 +26,12 @@ bool DeviceRenderer::PropagateEvent(SDL_Event* event) {
|
||||||
float x, y;
|
float x, y;
|
||||||
SDL_GetMouseState(&x, &y);
|
SDL_GetMouseState(&x, &y);
|
||||||
|
|
||||||
if (x >= bbox.x && x <= bbox.x + bbox.w && y >= bbox.y && y <= bbox.y + bbox.h) {
|
if (event->button.button == SDL_BUTTON_LEFT) {
|
||||||
selected = true;
|
if (x >= bbox.x && x <= bbox.x + bbox.w && y >= bbox.y && y <= bbox.y + bbox.h) {
|
||||||
grabbed = true;
|
selected = true;
|
||||||
return true;
|
grabbed = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (grabbed && event->type == SDL_EVENT_MOUSE_MOTION) {
|
} else if (grabbed && event->type == SDL_EVENT_MOUSE_MOTION) {
|
||||||
|
|
|
@ -13,7 +13,7 @@ void NetworkRenderer::AddDevice(std::shared_ptr<Device> device, uint16_t x, uint
|
||||||
}
|
}
|
||||||
|
|
||||||
void NetworkRenderer::PropagateEvent(SDL_Event* event) {
|
void NetworkRenderer::PropagateEvent(SDL_Event* event) {
|
||||||
if (event->type == SDL_EVENT_MOUSE_BUTTON_DOWN) {
|
if (event->type == SDL_EVENT_MOUSE_BUTTON_DOWN && event->button.button == SDL_BUTTON_LEFT) {
|
||||||
for (DeviceRenderer& device : devices) {
|
for (DeviceRenderer& device : devices) {
|
||||||
device.Deselect();
|
device.Deselect();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue