logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

widgetPlus - Enhanced Entry, Spinbox, and Combobox Widgets with Undo/Redo and other useful features

Bindings

CLASSBINDINGS
       The class binding tag for different widgets has these default values:

       •      entry           uses Entryspinbox         uses Spinboxttk::entry      uses TEntryttk::spinbox    uses TSpinboxttk::combobox   uses TComboboxentryPlus       uses EntryPlusspinboxPlus     uses SpinboxPlusttkEntryPlus    uses TEntryPlusttkSpinboxPlus  uses TSpinboxPlusttkComboboxPlus uses TComboboxPlusUNDOANDREDO
       The <<Undo>> and <<Redo>> virtual events are mapped to these keyboard events:

       •      On X11 systems (Linux®, BSD®, Solaris®, etc):

              •      <<Undo>> is mapped to <Control-z><<Redo>> is mapped to <Control-Shift-z>

       •      On Windows® systems:

              •      <<Undo>> is mapped to <Control-z><<Redo>> is mapped to <Control-y>

       •      On Aqua® systems (i.e. Apple® macOS® or OS X®):

              •      <<Undo>> is mapped to <Command-z><<Redo>> is mapped to <Command-Shift-z>ENTRYPLUS
       The EntryPlus bindings are based on those of the Entry bindtag, with these changes:

       •      New bindings to <<Undo>> and <<Redo>>.

       •      An adjustment to the <<Paste>> binding, so that it behaves  the  same  way  on  X11  as  on  other
              windowing systems (i.e. it deletes the existing selection, if any exists).

       •      The removal of the antiquated <Insert> binding.

       •      New   bindings   to   <FocusIn>   and   <FocusOut>,   to  facilitate  the  implementation  of  the
              -inactiveselectbackground option.

   SPINBOXPLUS
       The SpinboxPlus bindings are based on those of the Spinbox bindtag, with the same  changes  as  are  made
       when converting Entry to EntryPlus.

   TENTRYPLUS
       The TEntryPlus bindings are based on those of the TEntry bindtag, with these changes:

       •      New bindings to <<Undo>> and <<Redo>>.

   TSPINBOXPLUS
       The TSpinboxPlus bindings are based on those of the TSpinbox bindtag, with these changes:

       •      New bindings to <<Undo>> and <<Redo>>.

   TCOMBOBOXPLUS
       The TComboboxPlus bindings are based on those of the TCombobox bindtag, with these changes:

       •      New bindings to <<Undo>> and <<Redo>>.

Bugs

       This version of widgetPlus is intended to be compatible with all releases of Tk 8.5 and 8.6, and with the
       branches core-8-5-branch, core-8-6-branch,  and  trunk  in  the  source  code  repository  for  Tk.   Any
       incompatibility  with  any  of  these versions, for any Tk windowing system, should be reported as a bug.
       Please    report    such     in     the     category     widgetPlus     of     the     TklibTrackers
       [http://core.tcl.tk/tklib/reportlist].

Bugs, Ideas, Feedback

       This  document,  and  the package it describes, will undoubtedly contain bugs and other problems.  Please
       report such in the category  widgetPlus  of  the  TklibTrackers  [http://core.tcl.tk/tklib/reportlist].
       Please also report any ideas for enhancements you may have for either package and/or documentation.

Commands

widgetPlus::entryPlus ?create? pathName
              Create an entryPlus widget; or convert an existing entry widget into an entryPlus.

       widgetPlus::spinboxPlus ?create? pathName
              Create a spinboxPlus widget; or convert an existing spinbox widget into a spinboxPlus.

       widgetPlus::ttkEntryPlus ?create? pathName
              Create a ttkEntryPlus widget; or convert an existing ttk::entry widget into a ttkEntryPlus.

       widgetPlus::ttkSpinboxPlus ?create? pathName
              Create a ttkSpinboxPlus widget; or convert an existing ttk::spinbox widget into a ttkSpinboxPlus.

       widgetPlus::ttkComboboxPlus ?create? pathName
              Create  a  ttkComboboxPlus  widget;  or  convert  an  existing   ttk::combobox   widget   into   a
              ttkComboboxPlus.

       widgetPlus::EnableBWidget
              Enable  widgetPlus  to  modify  BWidgetEntry  widgets  and  their compounds (such as the BWidgetComboBox).  The command creates a bindtag BwEntryPlus to  replace  the  default  bindtag  BwEntry.
              This  operation  is  not  performed  when  the package is loaded because it requires BWidget to be
              loaded first.  This command is not exported from namespace ::widgetPlus.

Description

       The  widgetPlus  package  adds  new features to the widgets entry, spinbox, ttk::entry, ttk::spinbox, and
       ttk::combobox.

       The new features are Undo and Redo operations, a <<Selection>> event, and for the Tk  (unthemed)  widgets
       an -inactiveselectbackground option, and some minor fixes to bindings.  The new facilities closely follow
       those of the text widget.

       The  revised  entry,  spinbox,  ttk::entry,  ttk::spinbox,  and  ttk::combobox widgets are created by the
       commands        widgetPlus::entryPlus,         widgetPlus::spinboxPlus,         widgetPlus::ttkEntryPlus,
       widgetPlus::ttkSpinboxPlus, and widgetPlus::ttkComboboxPlus respectively.

       For  example,  the widgetPlus::entryPlus widget is implemented as a Snitsnit::widgetadaptor that wraps a
       Tkentry widget.  Its winfoclass is Entry, and it uses a binding tag EntryPlus that replaces  the  Entry
       binding tag.  The other widgets are implemented in a similar way.

       The  package  uses  the namespace ::widgetPlus, which exports (only) the five commands defined below that
       begin with a lower-case letter (EnableBWidget is not exported).  These commands can be imported into  the
       global  namespace, and for simplicity, descriptive text in this manual will henceforth omit the namespace
       qualifier.

              namespace import ::widgetPlus::*

Examples

       To create and map an entryPlus widget .ep with an unlimited Undo/Redo stack:

              package require widgetPlus
              widgetPlus::entryPlus .ep -undo 1 -maxundo 0
              pack .ep

       The same but using namespaceimport:

              package require widgetPlus
              namespace import widgetPlus::*
              entryPlus .ep -undo 1 -maxundo 0
              pack .ep

       To convert an existing entry widget .ee into an entryPlus with an unlimited Undo/Redo stack:

              entry .ee

                  .
                  .
                  .

              package require widgetPlus
              widgetPlus::entryPlus .ee -undo 1 -maxundo 0

       The same but using namespaceimport:

              entry .ee

                  .
                  .
                  .

              package require widgetPlus
              namespace import widgetPlus::*
              entryPlus .ee -undo 1 -maxundo 0

       Apply widgetPlus to a Bryan Oakley combobox:

              package require combobox
              combobox::combobox .cb

                  .
                  .
                  .

              package require widgetPlus
              namespace import widgetPlus::*
              entryPlus .cb.entry -undo 1 -maxundo 0

       Apply widgetPlus to a BWidgetComboBox.  The command ::widgetPlus::EnableBWidget must be called first.

              package require BWidget
              ComboBox .cb

                  .
                  .
                  .

              package require widgetPlus
              ::widgetPlus::EnableBWidget
              namespace import widgetPlus::*

              entryPlus .cb.e -undo 1 -maxundo 0

Name

       widgetPlus - Enhanced Entry, Spinbox, and Combobox Widgets with Undo/Redo and other useful features

See Also

       BWidget,   ComboBox,   Entry,  entry,  persistentSelection,  spinbox,  text,  ttk::combobox,  ttk::entry,
       ttk::spinbox

tklib                                                  1.0                                          wi...us(3tk)

Synopsis

       package require Tcl8.5

       package require Tk8.5

       package require snit

       package require widgetPlus?1.0?widgetPlus::entryPlus ?create? pathNamewidgetPlus::spinboxPlus ?create? pathNamewidgetPlus::ttkEntryPlus ?create? pathNamewidgetPlus::ttkSpinboxPlus ?create? pathNamewidgetPlus::ttkComboboxPlus ?create? pathNamewidgetPlus::EnableBWidgetpathNameedit ?argarg...?

       pathNameeditcanredopathNameeditcanundopathNameeditmodified ?boolean?

       pathNameeditredopathNameeditresetpathNameeditseparatorpathNameeditundo

________________________________________________________________________________________________________________

To Do

       •      Undo and Redo do not sync the value of the modifiedflag - they always set the  value  to  booleantrue.

       •      Undo and Redo do not sync the position of the insertion cursor.

       •      The <<Modified>> event is not generated.

       •      Undo/Redo  separators,  and  the  -autoseparators  option,  as  found  in the text widget, are not
              implemented. An implicit separator is added for each call to a  widget  command  (e.g.  insert  or
              delete)  that  changes  the widget contents.  The editseparator command has no effect.  Separator
              functionality would be less useful for widgets such as entryPlus than it is for a text widget.

       •      Add an overwrite mode, toggled by <Insert> on non-macOS® systems.

Use With Megawidgets

       When  an entry, spinbox, ttk::entry, ttk::spinbox, or ttk::combobox is a component of a megawidget, it is
       often possible to apply widgetPlus to that component without modifying the megawidget code.

   COMBOBOX(BYBRYANOAKLEY)
       A combobox with path $w includes an entry widget $w.entry,  which  uses  the  Entry  binding  tag.   Thus
       widgetPlus can be applied to the combobox after creation, using the command (see EXAMPLES)

              entryPlus $w.entry -undo 1 -maxundo 0

   COMBOBOX(BWIDGET)
       A  BWidgetComboBox  with  path  $w includes an entry widget $w.e, which uses the BwEntry binding tag in
       place of the default tag Entry.

       Package widgetPlus provides a replacement bindtag BwEntryPlus, but this is not computed when the  package
       is  loaded  because it requires BWidget to be loaded first.  The command ::widgetPlus::EnableBWidget must
       be called to provide BwEntryPlus, and then the BWidgetComboBox can be modified (see EXAMPLES)

              ::widgetPlus::EnableBWidget
              entryPlus $w.e -undo 1 -maxundo 0

Virtual Event <<Selection>>

       Each  widgetPlus  widget  generates  a  virtual  event  <<Selection>> whenever the value of its selection
       changes.  This allows other Tcl code,  for  example  the  package  persistentSelection,  to  monitor  the
       selection in these widgets.

Widget Commands

       In addition to the usual commands of the entry,  spinbox,  ttk::entry,  ttk::spinbox,  and  ttk::combobox
       widgets, the wrappers entryPlus, ttkEntryPlus, spinboxPlus, ttkSpinboxPlus, and ttkComboboxPlus provide:

       pathNameedit ?argarg...?
              This  command controls the undo mechanism and the modifiedflag. The exact behavior of the command
              depends on the option argument that follows the edit argument. The following forms of the  command
              are currently supported:

       pathNameeditcanredo
              Returns  a  booleantrue  if  redo  is possible, i.e. when the redostack is not empty. Otherwise
              returns false.

       pathNameeditcanundo
              Returns a booleantrue if undo is possible, i.e. when the  undostack  is  not  empty.  Otherwise
              returns false.

       pathNameeditmodified ?boolean?
              If  boolean  is  not  specified, returns the modifiedflag of the widget. The insert, delete, editundo and editredo commands, or (by using this command) the user, can set or  clear  the  modifiedflag. If boolean is specified, sets the modifiedflag of the widget to boolean.

       pathNameeditredo
              When  the  -undo option is true, reapplies the last undone edits provided no other edits were done
              since then. Generates an error when the redostack is empty. Does nothing when the -undo option is
              false.

       pathNameeditreset
              Clears the undostack and redostack.

       pathNameeditseparator
              Included for completeness, but has no effect.

              (N.B. An implicit separator is added to the undostack for each call to  a  widget  command  (e.g.
              insert  or  delete)  that  changes  the widget contents.  These therefore separate the addition or
              removal of individual characters by typing, except that cut or paste operations are discrete.)

       pathNameeditundo
              Undoes the last edit action when the -undo option is true. An edit action is defined as  a  single
              insert  or  delete  command  that  is recorded on the undostack. Generates an error when the undostack is empty. Does nothing when the -undo option is false.

Widget Options

       In addition to the usual options of the  entry,  spinbox,  ttk::entry,  ttk::spinbox,  and  ttk::combobox
       widgets,  the  wrappers entryPlus, spinboxPlus, ttkEntryPlus, ttkSpinboxPlus, and ttkComboboxPlus provide
       the options below.

       Command-Line Switch:    -inactiveselectbackground
       Database Name:          inactiveSelectBackground
       Database Class:         Foreground

              Specifies the color to use for the selection when the window does not have  the  input  focus.  If
              empty,  {},  then  no  selection  is  shown  when  the  window  does  not  have  the  focus.   The
              -inactiveselectbackground  option  has  no  effect  on  the  Ttk  (themed)  widgets  ttkEntryPlus,
              ttkSpinboxPlus, and ttkComboboxPlus.

       Command-Line Switch:    -maxundo
       Database Name:          maxUndo
       Database Class:         MaxUndo

              Specifies  the  maximum  number  of  compound undo actions on the undostack. A zero or a negative
              value imply an unlimited undostack.

       Command-Line Switch:    -undo
       Database Name:          undo
       Database Class:         Undo

              Specifies a boolean that says whether the undo mechanism is active or not.

See Also