I'm using this for something and I'd like to have icons on buttons. Is there a way to do that and still have three shades of button (idle, hovered, being pressed - I want entire sprite to change tint a little like normal buttons do) or not?
Also, is there some more powerful button function that'd let me catch right click or double click separately (I assume double click is possible in my code but I ask about a built in method)? I have a need to do one thing when button is pressed and another when it's double/right clicked.
And I have this code (inside a window begin+end pair of course) and it works only for the first right button, is that something with ids, using same texture, etc? What do I do?sf::Sprite spr(m_iconstex);
for(int i = 0; i < 5; ++i)
{
spr.setTextureRect(sf::IntRect(0, i * 32, 32, 32));
if(imgui::ImageButton(spr, 1))
std::printf("bum right\n");
imgui::SameLine();
spr.setTextureRect(sf::IntRect(32, i * 32, 32, 32));
if(imgui::ImageButton(spr, 1))
std::printf("bum left\n");
}
I now changed it to
sf::Sprite spr(m_iconstex);
for(int i = 0; i < 5; ++i)
{
spr.setTextureRect(sf::IntRect(0, i * 32, 32, 32));
imgui::PushID(2 * i + 0);
if(imgui::ImageButton(spr, 1))
std::printf("bum right\n");
imgui::PopID();
imgui::SameLine();
spr.setTextureRect(sf::IntRect(32, i * 32, 32, 32));
imgui::PushID(2 * i + 1);
if(imgui::ImageButton(spr, 1))
std::printf("bum left\n");
imgui::PopID();
}
and it works. I skimmed through the primer on ids in the faq and read your image button source and then image button function that it calls and it uses texture as id so that's why this happened.