# 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:** 1\
**Showing post:** 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)

---

_[View the full topic](https://root-forum.cern.ch/t/tpad-waitprimitive/5765)._
