| 610 | } |
| 611 | |
| 612 | void SampleApp::OnAddButtonHClick() { |
| 613 | auto button = sfg::Button::Create( L"New ->" ); |
| 614 | |
| 615 | auto ouchy = std::make_shared<Ouchy>( button ); |
| 616 | Ouchy::m_ouchies.push_back( ouchy ); |
| 617 | |
| 618 | std::weak_ptr<Ouchy> weak_ouchy = ouchy; |
| 619 | |
| 620 | button->GetSignal( sfg::Widget::OnLeftClick ).Connect( [weak_ouchy] { |
| 621 | auto strong_ouchy = weak_ouchy.lock(); |
| 622 | |
| 623 | if( strong_ouchy ) { |
| 624 | strong_ouchy->DoOuch(); |
| 625 | } |
| 626 | } ); |
| 627 | |
| 628 | m_boxbuttonsh->Pack( button, true ); |
| 629 | } |
| 630 | |
| 631 | void SampleApp::OnAddButtonVClick() { |
| 632 | auto button = sfg::Button::Create( L"<- New" ); |