1
\$\begingroup\$

I'm trying to add GUI for easier level editing in our game engine. We're using SFML for all the basic stuff (window management, input events etc). I've chosen AntTweakBar because it is a well known library with a few examples around. I was following the tutorial at AntTweakBar's website

I was able to draw a simple bar with those example codes. However, mouse events received by SFML are not registered by AntTweakBar's TwEventSDL() function. Here is an example code for Input:

sf::Event event;
while (_pWindow->pollEvent(event))
{
    // Check if the event should be handled by AntTweakBar
    int handled = TwEventSFML(&event, 2, 3); // for SFML version 2.3
    if (!handled){
        switch (event.type)
        {
        case sf::Event::MouseButtonPressed: // To check whether SFML received mouse button events properly
            if (event.mouseButton.button == sf::Mouse::Button::Left){
                std::cout << "Left button pressed" << std::endl;
                std::cout << "x: " << event.mouseButton.x << std::endl;
                std::cout << "y: " << event.mouseButton.y << std::endl;
            }
        }
    }
    else{ //To check whether TwEventSFML received events
        std::cout << "FINALLY!" << std::endl;
    }

When I press buttons, I can see "FINALLY!" showing up. I can also see that my mouse clicks are received by SFML. However, when I click on an AntTweakBar element (be it a button or help section) it doesn't register it. (Also, I can't see "FINALLY!" when I use the mouse).

Any help or ideas will be appreciated.

\$\endgroup\$
1
  • 1
    \$\begingroup\$ I'm not sure and just guessing here, but you might need to patch the code. AntTweakBar hasn't been updated in a while and its SFML integration is for 1.x and not 2.x. While I vastly prefer the model of AntTweakBar, you might look into ocornut's imgui as a supported alternative, if you don't want to modify and update AntTweakBar. \$\endgroup\$ Feb 14, 2016 at 5:08

1 Answer 1

2
\$\begingroup\$

Anttweakbar hasnt been updated in 3 years, last SFML integration was for SFML 1.6 Are you using SFML 1.6 ? if not then you have to create your own input handler for it.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .