bindCallback: I'm doing something dumb.

Started by CombatWombat, 24 October 2013, 04:01:59

CombatWombat


class Widget
{
public:
    Widget(dp::Gui &gui, const std::string &name);

protected:
    std::string name;
    tgui::Picture::Ptr icon;
    tgui::ChildWindow::Ptr popupWindow;
};

// and in an inherited class...
ConnectionBlock::ConnectionBlock(dp::Gui &gui, const std::string &name) : Widget(gui, name)
{
      popupWindow->loadWidgetsFromFile("Forms/ConnectionBlockPopup.txt");
      icon->load("Images/Icons/db9.png");
      icon->bindCallback(&tgui::Widget::show, popupWindow, tgui::Button::LeftMouseClicked);
}


I can't get the last line to work.  I get a variety of "no matching function for call..." errors.
Should the instance of the object get a &?  I think not, because it is already a ChildWindow::Ptr (it is already an address).
Does it matter that popupWindow is a ChildWindow, and i am binding a function from Widget?  (ChildWindow IS a Widget). 

I suspect I am doing something elementary incorrectly with function binding.

Thanks.

texus

The function is for binding functions in your own classes, so it expects a normal pointer and not a smart pointer (the popupWindow).

You'll need to write it like this (get returns the internal pointer).
icon->bindCallback(&tgui::Widget::show, popupWindow.get(), tgui::Button::LeftMouseClicked);