I have a popup system (GUI) that does this:
// creates popup with two possible answer-buttons
if (timeToEat())
callPopup(ID_4, "What to eat?", "Cake", "Cookies!");
//elsewhere in code i check for key presses
if (popupAnswered(ID_4,0)) // clicked first button in popup
eatCake();
if (popupAnswered(ID_4,1)) // clicked second button in popup
eatCookiesDamnit();
Could I use some kind of lambda/callback to arrange it like below. So that the function "remains" and can be activated when the button in is was pressed (a value was returned).
Thanks!
if (timeToEat())
callPopup("What to eat?", "Cake", "Cookies!"){
<return was 0 :> eatCake(); break;
<return was 1 :> eatCookies(); break;
}