You can change your inheritance tree. File::Spec does this. Whether it's a good idea or not is another story.

The problem with changing your inheritance tree is that it affects all objects of that type, or that are derived from that type. For File::Spec, being that it can't be recast as a different platform, this seems ok. For you, this may be a show-stopper.

How I would do this in C++ would be to create a proxy object, a factory to create them, and then call through the proxy for everything. So your Tk::MyEntryCheck object would contain another object in it through a HASA relationship (rather than the ISA relationship you're trying to do). And then you could just replace that object at runtime with a different object that did different things. The advantage is that you can have multiple Tk::MyEntryCheck objects, each of which have different proxy objects that are unrelated to each other, and it can all work.

Another way is to create a new package, set it so it ISA Tk::MyEntryCheck, and put the code in there. In other words, reverse the inheritance tree from what you're trying to do. The problem here is trying to ensure that you can fully swap out one entry-check object with another which sometimes can be more difficult, but, if it can be done, it may be less code than the HASA method above.


In reply to Re: Userdefined Tk::Derived parent for Widget-Addon by Tanktalus
in thread Userdefined Tk::Derived parent for Widget-Addon by strat

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.