# TPad::WaitPrimitive()

**URL:** <https://root-forum.cern.ch/t/tpad-waitprimitive/5765>\
**Category:** ROOT\
**Created:** [December 10, 2007, 2:07pm UTC](https://root-forum.cern.ch/t/tpad-waitprimitive/5765 "2007-12-10T14:07:45Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mertz](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/m/bc8723/32.png) [@mertz](https://root-forum.cern.ch/u/mertz)\
**Post date:** [December 10, 2007, 2:07pm UTC](https://root-forum.cern.ch/t/tpad-waitprimitive/5765/1 "2007-12-10T14:07:45Z")

</div>

Hello, I want the User to click in a Canvas before I clean up my class’ resources. Therefore I wrote the following code:

` ~TMyClassImpl() 
  { 
    if (leaveopen_) {
      try {
        auto_ptr<TCanvas> clickme ( new TCanvas("clickme", "clickme", -200,200,300,140));
        TText t(0.1,0.5,"Double click or press a key.");
        t.Draw();
        clickme->cd();
        clickme->WaitPrimitive();
        }
      }
      catch (...) {}
    }
    /* clean up resources */
  }
 `

The program did not wait for the clicks so I put in the example code from [root.cern.ch/root/html514/TPad.h … tPrimitive](http://root.cern.ch/root/html514/TPad.html#TPad:WaitPrimitive)  
getting the following output:

`Loop i=30, found objIsA=TText, name=` - over 50 times. Is there a way to get WaitPrimitive() to ignore the former Insertion of the TText and wait for the double-click or pressed key as intended? (I am using root 5.14)

---

<div class="post-metadata">

**Author:** ![pcanal](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/pcanal/32/12439_2.png) [@pcanal](https://root-forum.cern.ch/u/pcanal)\
**Post date:** [December 10, 2007, 4:05pm UTC](https://root-forum.cern.ch/t/tpad-waitprimitive/5765/2 "2007-12-10T16:05:39Z")

</div>

You problably need to add

`clickme->Update();`just after the Draw.

Cheers,  
Philippe
