changeset 59504:66f927c186ac

(Links and Mouse-1): Rename section from Enabling Mouse-1 to Following Links. Change xrefs. Add examples for define-button-type and define-widget.
author Kim F. Storm <storm@cua.dk>
date Wed, 12 Jan 2005 15:32:47 +0000
parents 97fd558f25ad
children 19b4e3d63aed
files lispref/text.texi
diffstat 1 files changed, 28 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/lispref/text.texi	Wed Jan 12 15:32:26 2005 +0000
+++ b/lispref/text.texi	Wed Jan 12 15:32:47 2005 +0000
@@ -2431,8 +2431,7 @@
                              only when text is examined.
 * Clickable Text::         Using text properties to make regions of text
                              do something when you click on them.
-* Enabling Mouse-1 to Follow Links::
-                           How to make @key{mouse-1} follow a link.
+* Links and Mouse-1::      How to make @key{Mouse-1} follow a link.
 * Fields::                 The @code{field} property defines
                              fields within the buffer.
 * Not Intervals::	   Why text properties do not use
@@ -3390,9 +3389,10 @@
 global definition) remains available for the rest of the text in the
 buffer.
 
-@node Enabling Mouse-1 to Follow Links
-@subsection Enabling Mouse-1 to Follow Links
+@node Links and Mouse-1
+@subsection Links and Mouse-1
 @cindex follow links
+@cindex mouse-1
 
   The normal Emacs command for activating text in read-only buffers is
 @key{Mouse-2}, which includes following textual links.  However, most
@@ -3402,9 +3402,10 @@
 customize this behaviour through the variable
 @code{mouse-1-click-follows-link}.
 
-  To define text as a link at the Lisp level, you should bind
-@key{Mouse-2} to a command to follow the link.  Then, to indicate
-that @key{Mouse-1} should also follow the link, here is what you do:
+  To define text as a link at the Lisp level, you should bind the
+@code{mouse-2} event to a command to follow the link.  Then, to
+indicate that @key{Mouse-1} should also follow the link, here is what
+you do:
 
 @table @asis
 @item @code{follow-link} property
@@ -3479,13 +3480,30 @@
   To define @key{Mouse-1} to activate a button defined with
 @code{define-button-type}, give the button a @code{follow-link}
 property with a value as specified above to determine how to follow
-the link.
-@c ??? That is not clear.  This needs an example or an xref.
+the link.  For example, here is how Help mode handles @key{Mouse-1}:
+
+@smallexample
+(define-button-type 'help-xref
+  'follow-link t
+  'action #'help-button-action)
+@end smallexample
 
   To define @key{Mouse-1} on a widget defined with
 @code{define-widget}, give the widget a @code{:follow-link} property
 with a value as specified above to determine how to follow the link.
-@c ??? That is not clear.  This needs an example or an xref.
+
+For example, here is how the @code{link} widget specifies that
+a @key{Mouse-1} click shall be translated to @key{RET}:
+
+@smallexample
+(define-widget 'link 'item
+  "An embedded link."
+  :button-prefix 'widget-link-prefix
+  :button-suffix 'widget-link-suffix
+  :follow-link "\C-m"
+  :help-echo "Follow the link."
+  :format "%[%t%]")
+@end smallexample
 
 @defun mouse-on-link-p pos
 @tindex mouse-on-link-p