From d36c42038d9e00906861468b2beb51f03e947416 Mon Sep 17 00:00:00 2001 From: "Zed A. Shaw" Date: Sun, 17 Nov 2024 16:00:57 -0500 Subject: [PATCH] Simple mouse clicks working but probably wrong coordinates. --- gui.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/gui.cpp b/gui.cpp index 9530428..ba8e526 100644 --- a/gui.cpp +++ b/gui.cpp @@ -200,6 +200,13 @@ bool GUI::handle_ui_events() { } else if(sf::Keyboard::isKeyPressed(sf::Keyboard::Enter)) { $status_ui.$component->OnEvent(Event::Return); } + } else if(sf::Mouse::isButtonPressed(sf::Mouse::Left)) { + sf::Vector2i pos = sf::Mouse::getPosition($renderer.$window); + Mouse mev; + mev.button = Mouse::Button::Left, + mev.x=pos.x / $renderer.$ui_bounds.width; // this needs to be in...panel coordinates? + mev.y=pos.y / $renderer.$ui_bounds.height; + $status_ui.$component->OnEvent(Event::Mouse("", mev)); } }