[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."
(interactive)
(switch-to-buffer "*Widget Example*")
(kill-all-local-variables)
(let ((inhibit-read-only t))
(erase-buffer))
(remove-overlays)
(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)
(test-widgets))
"Reset Form")
(widget-insert "\n")
(use-local-map widget-keymap)
(widget-setup))
(defun tw-change-value ()
(interactive)
(widget-value-set tw-value-field "Changed value")
(widget-setup))
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.
- widget-value-set for editable fields,
Markus Triska <=