Tk::ObjEditor - Tk composite widget Obj editor
use Tk::ObjEditor; my $editor = $mw->ObjEditor( caller => $object, direct => [1|0], [title=>"windows"]) -> pack ;
This widget provides a GUI to edit the attributes of an object or the elements of a simple hash or array.
The editor is a Tk::ObjScanner with additional function to edit data. The editor can be used in an autonomous way with the
When the user double clicks (with left button) on an item, the value of the item will be displayed in the HList.
If the value is a scalar, the scalar will be displayed in the text window. (Which is handy if the value is a multi-line string)
If you use the middle button and the item (either hash, array or scalar) is tied to an object , you will open the object hidden behind the tied variable.
Use the right button of the mouse of an element to modify its value. Depending on the context, you will also be able to delete the element or to add a sub-element.
This may be not clear. If yes, I think that trying this widget will be much clearer than any explanation I can write. So run the Tk widget demo and you'll find the Obj editor demo in the "User Contributed Demonstration" section.
As the constructor will pass a reference to the data structure to be edited, the data can be edited :
In this case, the data structure is cloned. The widget will edit the cloned version of the data structure. This enable the user to cancel the edition. This means that any reference to the internals of old data structure will stay on the old datastructure and will not be aware of the new values entered with this widget.
Unforunately, undirect edition will break if the cloned data structure contains code reference.
In this case, the data structure is not cloned. The edition is performed on the passed reference. Any reference to the internals of old data structure will be updated on-line. The drawback is that the user cannot cancel (or undo) the edition.
This function is not exported and must be called this way:
This function will load Tk and pop up an editor widget. When the user destroy the widget (with
File - destroy> menu), the user code is resumed.
Like Tk::ObjScanner ObjEditor does not detect recursive data structures. It will just keep on displaying the tree until the user gets tired of clicking on the HList items.
ObjEditor cannot edit code reference. The module will break if you try undirect edition of data containing code references.
Dominique Dumont (email@example.com), Guillaume Degremont.
Copyright (c) 1997-2004,2007 Dominique Dumont, Guillaume Degremont. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.