The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Tk::ObjEditor - 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.

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.

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 (optionnal)

  • direct: Set to 1 if you want to perform direct edition.

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.

AUTHOR

Dominique Dumont (Dominique_Dumont@hp.com), Guillaume Degremont.

Copyright (c) 1997-2003 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.

SEE ALSO

perl(1), Tk, Tk::HList, Tk::ObjScanner