On Thu, 2003-12-18 at 21:23, James Tillman wrote:
> On Thu, 2003-12-18 at 16:57, Stephen Gunnell wrote:
> > Hi James,
> > I'm still beating my head against the vagaries of Create Project / Open
> > Project. Admittedly the thumps are pretty widely spaced at the
> > moment.However I am about to have 2 weeks enforced leave during which I
> > should be able to do something.8-)
> > I have obtained and read the drag and drop tutorials but that doesn't
> > seem to be quite how Form Builder works. Can you provide an outline
> > please?
> Stephen: I remember the process of creating the widget that gets
> dropped was rather complex, and it's been a while since I looked at that
> code. I'll review it over the weekend and try to send along a passable
> description of what goes on.
Okay, I've refreshed my memory. There are 2 things going on in Guido
that involve dragging and dropping.
The first is the "draggability" of widgets that have been added to a
Form that is being designed in the IDE. This draggability is enabled
via a special module called WidgetDrag. It essentially lobotomizes the
widget in question and applies some drag-event trickery that allows you
to click on it and drag it around the form. All the interesting stuff
is in lib/WidgetDrag. This module is used exclusively (at the moment)
by lib/Plugin/FormBuilder, which serves as something akin to the
"controller" in Guido's MVC-esque design.
The second drag&drop thing in Guido (and that which you are currently
interested in) is drag&drop of widgets from the Toolbox onto the
FormBuilder's forms. Unfortunately, as mentioned earlier, the ability
to add widgets is completely broken at the moment. I will attempt to
explain the way it's SUPPOSED to work:
* You click on a widget in the Toolbox and drag it toward the form. At
this point, the drag event has fired on the Tk::Button widget that sits
in the Toolbox (this button has a JPEG on it that looks like the widget
it's supposed to create). You can find the code that creates the button
widget and sets up the drag event in lib/Guido/Plugin/Toolbox.pm's
* Then, the widget is dropped on the Form (or another container widget
in the form, such as a Frame or something). This widget is supposed to
receive the Drop event and request the creation of the widget by calling
Toolbox->create_active_widget(). Then Toolbox in turn calls the
add_widget() method on the widget that just called it so the new widget
can be added.
However, it seems that the Guido::SourceFile::TkForm module is missing
any Drop event handling. The Tk::SourceFile::TkWidget::Basic module
(which handles widgets that are placed on a Form) does have such code
(see the request_widget() method), so this means that if you can ever
get a container type widget added to a form, dragging and dropping
widgets on the container should add them as children.
Whew. You may not know it, but drag&drop is the second method we added
for putting a widget on the Form. The primary method was to just click
the button in the Toolbox. This proved much more straightforward, since
the Toolbox could just create the widget and pass it to the currently
active Form. Unfortunately, it looks like even THIS functionality is
now broken, and I have no idea why without digging deeper into the code.
By now you may have noticed that there's some similarities between
Guido::SourceFile::TkForm and Guido::SourceFile::TkWidget::Basic.
Essentially, the TkForm is just a TkWidget::Basic that is a top-level
window and knows how to persist itself to a file. There's almost
certainly redundant code in there.
I think it would be wise to concentrate on re-enabling the ability to
add a widget to a form by clicking the Toolbox button, and then fix the
draggability of widgets on a form. Once this basic functionality is
restored, then the drag&drop of widgets onto the form can be tackled.
It's more complex than you think once you realize that container widgets
such as Frames have to be able to receive drops, too.
I hope this at least gets you closer to an understanding. As questions
arise, please email the list and I'll respond. I also hope to find at
least a little time to do some work on Guido over the next month or so,
but that is not definite.
Stephen: Your time and attention to Guido (any that you manage to
spare) is greatly appreciated.