Tk::ObjEditor(3) Tk composite widget Obj editor

SYNOPSIS


use Tk::ObjEditor;

my $editor = $mw->ObjEditor( caller => $object,
direct => [1|0],
[title=>"windows"]) -> pack ;

DESCRIPTION

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 "edit_object" function.

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.

Direct or undirect edit

As the constructor will pass a reference to the data structure to be edited, the data can be edited :
not directly
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.

directly
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.

Constructor parameters

  • -caller: The ref of the object or hash or array to edit (mandatory).
  • -title: the title of the menu created by the editor (optional)
  • -direct: Set to 1 if you want to perform direct edition.

Autonomous widget

edit_object( data )

This function is not exported and must be called this way:

  Tk::ObjEditor::edit_object($data);

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.

CAVEATS

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.

AUTHOR

Dominique Dumont (ddumont at cpan.org), Guillaume Degremont.

LICENSE

Copyright (c) 1997-2004,2007,2014 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.