[Top][All Lists]

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

Re: widget-value-set for editable fields

From: Lennart Borgman (gmail)
Subject: Re: widget-value-set for editable fields
Date: Fri, 02 Feb 2007 00:47:51 +0100
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv: Gecko/20061207 Thunderbird/ Mnenhy/

Markus Triska wrote:
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.

Testing this I found that if I tab to the field and do

  M-: (marker-insertion-type (widget-get (widget-at (point)) :from))

it returns t which I believe mean that the marker at the field beginning moves forward when inserting text there.

reply via email to

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