Hello, completely new here.
I couldn't find help in the official documents, tutorials nor examples about how to detect just a single mouse click/release on a button.
Button->OnClick() - Function executes multiple times when it's called?? Or is there another way to detect if the button was clicked? And it's not because of the for-loop. Even without it the functions get called multiple times.
This is my code I'm trying to get to work:
I couldn't find help in the official documents, tutorials nor examples about how to detect just a single mouse click/release on a button.
Button->OnClick() - Function executes multiple times when it's called?? Or is there another way to detect if the button was clicked? And it's not because of the for-loop. Even without it the functions get called multiple times.
This is my code I'm trying to get to work:
Code Select
void useItem(const Player::ptr& player, const Item::ptr& item)
{
if (!player)
return;
if (!item)
return;
item->use(player.get());
}
void HUD::update()
{
// Check if inventory slot was clicked
for (int i = 0; i < NUM_INVENTORY_SLOTS; ++i)
{
m_inventory[i]->onClick(useItem, m_player, m_player->getItemByIndex(i));
}
}