/* Crafter®.Graphics Copyright (C) 2025 Catcrafts® Catcrafts.net This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3.0 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include #include import Crafter.Graphics; //Needed for events import Crafter.Event; using namespace Crafter; int main() { // Create a Wayland window named "HelloWindow" with resolution 1280x720 // (window creation explained in HelloWindow example) WindowWaylandWayland window("HelloWindow", 1280, 720); // Listen for left mouse click events on the window // The callback receives the MousePoint struct containing the click coordinates in float pixels from the top left corner EventListener clickListener(&window.onMouseLeftClick, [](MousePoint point){ // Print the coordinates where the user clicked std::cout << std::format("Clicked on X:{} Y:{}!", point.x, point.y) << std::endl; }); // Listen specifically for the 'a' key being pressed down // The callback takes no parameters since the key is fixed EventListener keyAListener(&window.onKeyDown['a'], [](){ // Print confirmation of 'a' key press std::cout << std::format("Pressed specifically the a key!") << std::endl; }); // Listen for any key press on the window // The callback receives the character of the key pressed EventListener anyKeyListener(&window.onAnyKeyDown, [](char key){ // Print which key was pressed std::cout << std::format("Pressed the {} key!", key) << std::endl; }); // Start the window event loop, unless the window is started events will not trigger. window.StartSync(); }