According to the LuaBridge readme, LuaBridge does not support "Enumerated constants", which I assume is just enums
. Since sf::Event
is almost entirely enums
, is there any way I can expose the class? Currently the only other solution I can come up with is detect key presses in C++, then send a string to Lua, that describes the event. Obviously, there are around 100+ keys on a modern keyboard, which would cause a massive, ugly segment of just if statements.
For those who haven't used SFML: Link to sf::Event class source code
UPDATE:
After attempting to create the function outlined in my question, I discovered that it don't work anyway, because you can't return more than one string in C++, so most events are ignored.
Example Source (doesn't work):
std::string getEvent()
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed) {window.close(); return "";}
else if (event.type == sf::Event::GainedFocus) {return "GainedFocus";}
else if (event.type == sf::Event::LostFocus) {return "LostFocus";}
else if (event.type == sf::Event::Resized) {return "Resized";}
else if (event.type == sf::Event::TextEntered)
{
if ((event.text.unicode < 128) && (event.text.unicode > 0)) {return "" + static_cast<char>(event.text.unicode);}
}
else if (event.type == sf::Event::KeyPressed)
{
//If else for all keys on keyboard
}
else if (event.type == sf::Event::KeyReleased)
{
//If else for all keys on keyboard
}
else {return "";}
}
return "";
}
UPDATE UPDATE:
Since this question has received zero comments or answers, I've decided not to rule out other libraries. So, if there is a C++ library that supports enums, I will accept it
__gc
metamethod so you can free the C++ memory when the Lua userdata is garbage collected. That has absolutely nothing to do with whether or not that C++ object is a union. The fact the the object may contain unions or bitfields or packing/alignment pragmas has no bearing whatsoever on this discussion in any way. – Sidoniasf::Event
, and more about objects with Unions and Enums in general, should I edit the question to remove all references to SFML? (that's if the reason the question got no answers was because the SFML tag scared people off) – Admix