Kyle R . Burton on Wed, 25 Jul 2001 15:47:00 -0400


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: drag and drop with Perl/Tk under Win32


> Hrm...now that I've explained that, maybe I should check the value of
> $self to see if one of the drop handlers are in fact different.  Perhaps
> there can only be 1 DropSite?

Actualy, I think I've worked around this for now.  Printing out the
value of $self showed that indeed only the first DropSite (and callback)
were being used by Tk.  

Each of my view objects keeps a reference back to the application so
they can initiate actions like updating the UI.  The update method in
turn updates the main menu and toolbar to enable/disable actions as
appropriate (save, save as, close file, etc.).  Through that back
reference, the drop handler can access the current view.  So the drop
handler ends up looking like this:

  sub dropHandler
  {
    my $self = shift()->app()->currentView();
    ...
  }

In effect I end up using a pseudo-global to get to the real $self.

This even seems to work under the condition when the first view is
closed (all the associated widgets are destroyed) - the drag and drop
continues to work for the second view.  I suppose the closure [callback]
is maintaining a reference to the first view's $self, which would cause
it's refcount not to reach 0.

If anyone has any advice/insight, I'd still love to hear it (or a second
opinion the approach).


Thanks,
Kyle R. Burton


-- 

------------------------------------------------------------------------------
Medicine cures sickness.
All the world is medicine.
What is the self?
        -- Yunmen
mortis@voicenet.com                            http://www.voicenet.com/~mortis
------------------------------------------------------------------------------
**Majordomo list services provided by PANIX <URL:http://www.panix.com>**
**To Unsubscribe, send "unsubscribe phl" to majordomo@lists.pm.org**