[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[widget] defining a widget that propagates a property to its children
From: |
Oliver Scholz |
Subject: |
[widget] defining a widget that propagates a property to its children |
Date: |
Sat, 05 Jul 2003 11:11:34 +0200 |
User-agent: |
Gnus/5.1002 (Gnus v5.10.2) Emacs/21.3.50 (windows-nt) |
I am trying to define some rather complex combined widgets that
(among other things) shall propagate some of their properties to
their children.
A simple case is a cons widget consisting of two editable fields. If
I create this modified cons widget with the :size property specified,
this :size property shall apply to the editable fields.
This task is as simple as getting the :size property from the parent
widget and putting it on all children somewhere in the creation
process of the widget without modifying anything else.
But, alas, I couldn't find out how to do this.
I first tried to do it in a function specified with the
:convert-widget property, but at this time there is not enough
information available (come to think of it, I guess that I don't
really understand what the :convert-widget function is supposed to
do).
I was able to come close with this kludge:
(define-widget 'cus-fontset-cons 'cons
"FIXME"
:format "%v"
:args '((editable-field
:format "%v\n"
:create cus-fontset-create-cons-item
)
(editable-field
:format "%v\n"
:create cus-fontset-create-cons-item
)))
(defun cus-fontset-create-cons-item (wid)
(setq wid (widget-convert wid))
(widget-put wid :size
(widget-get (widget-get wid :parent)
:size))
(widget-default-create wid))
(defvar egoge-test-widget nil)
(make-variable-buffer-local 'egoge-test-widget)
(progn (switch-to-buffer (generate-new-buffer "*test*"))
(setq egoge-test-widget
(widget-create 'cus-fontset-cons
:size 40
:value
'("lirum" . "larum")))
(widget-setup)
(use-local-map widget-keymap))
Unfortunately this wreaks havoc with the editable fields: edit one of
those fields and type
`M-: (widget-value egoge-test-widget) RET'
The value is not updated to the actual content of the editable field
in the buffer.
What can I do?
Oliver
--
17 Messidor an 211 de la Révolution
Liberté, Egalité, Fraternité!
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [widget] defining a widget that propagates a property to its children,
Oliver Scholz <=