[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

widget-value-set for editable fields

From: Markus Triska
Subject: widget-value-set for editable fields
Date: Thu, 01 Feb 2007 18:50:29 +0100

Here is a simple widget example:

    (require 'widget)
    (require 'wid-edit)

    (defvar tw-value-field nil)

    (defun test-widgets ()
      "Create some widgets."
      (switch-to-buffer "*Widget Example*")
      (let ((inhibit-read-only t))
      (widget-insert "Here is some documentation.\n\Value: ")
      (setq tw-value-field
            (widget-create 'editable-field
                           :size 50
                           :format "%v "
      (widget-insert "\n")
      (widget-create 'push-button
                     :notify (lambda (&rest ignore)
                     "Reset Form")
      (widget-insert "\n")
      (use-local-map widget-keymap)

    (defun tw-change-value ()
      (widget-value-set tw-value-field "Changed value")

M-x test-widgets creates a buffer with 2 widgets. M-x tw-change-value
sets the editable field's value to "Changed value" at any time. This
works well if the widget's current value is the empty string. In
contrast, if you enter anything in the editable field, and then do
M-x tw-change-value, its previous value still occurs in the buffer.
Tested with CVS trunk.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]