portrait

Поиск



[software] [catdoc] [tcl] [geography] [old things]

Textprops package

Right-click menus for entry and text widgets

Tk by default doesn't provide right-click bindings for entry and text widgets. But user typically expect that right click on the edit area would bring up a menu with common edit operations.

textprops package fixes this problem. Loading this file create bindings for Text and Entry bindtags which bring up tk_popup with common edit operations.

Even more, bindings check state of widget and system clipboard and disable some entries appropriately.

It also has function textprops::StdEditMenu which allows to fill previously created menu with standard edit commands and adds a -postcommand which control their state.

::textprops::StdEditMenu menu text-widget
where text widget is the name of text widget which should be controlled by the menu. Variable and command substitution can be used in the text-widget name. So it is possible to use single edit menu for multiple text windows if you figure out how to pick current one.

Package uses msgcat package to localize menu entries. Currently no .msg files provided and no mcload is called. Russian localization is built directly into package code (.i.e mcmset command).

Limitations

  1. Undo/Redo are missing for entry widget, because tk lacks undo stack on entry widgets
  2. Redo is always enabled for text widgets with enabled undo mechanism, because I couldn't find way to check whether redo is possible
  3. No support for switching encodings on the fly. Inserted files are always assumed to be in system encoding
  4. No support for per-widget setting of filetypes allowed to be inserted