vendredi 17 août 2018

wxTimer not calling overriden Notify()

I'm running into an issue where I implemented a derived wxTimer class to override the Notify() call since I'm not using an owner implementation as described in the documentation.

When I debug the run, I can see

  • the timer is being instantiated
  • my_timer_instance->IsRunning() returns true
  • MyTimer::Notify() is never called

This leads me to believe that the timer is being set and running, but when it expires it's calling the base class Notify() procedure and not my override but I'm not sure why.

.hpp

class MyFrame : public wxFrame
{
   friend class MyTimer;
   MyTimer* my_timer_instance;

protected:
   wxStaticText* HelloWorldLabel;
public:
   void updateHelloWorldLabel(std::string new_text);
   void setTimer(MyTimer* timer){my_timer_instance = timer;}
   MyTimer* getTimer(){return my_timer_instance;}

};

class MyTimer : public wxTimer
{
   void Notify() override;
};

.cpp

MyFrame::updateHelloWorldLabel(std::string new_text)
{
    HelloWorldLabel->SetLabelText(new_text);
}   

void MyTimer::Notify()
{
   frame->updateHelloWorldLabel("Timer popped!");       
}

MyApp

frame->setTimer(new MyTimer);
frame->getTimer()->Start(5000);

Aucun commentaire:

Enregistrer un commentaire