/[emacs]/emacs/lispref/text.texi
ViewVC logotype

Diff of /emacs/lispref/text.texi

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.82 by rms, Thu Jan 6 17:44:55 2005 UTC revision 1.83 by kfstorm, Tue Jan 11 00:12:09 2005 UTC
# Line 2431  along with the characters; this includes Line 2431  along with the characters; this includes
2431                               only when text is examined.                               only when text is examined.
2432  * Clickable Text::         Using text properties to make regions of text  * Clickable Text::         Using text properties to make regions of text
2433                               do something when you click on them.                               do something when you click on them.
2434    * Enabling Mouse-1 to Follow Links::
2435                               How to make @key{mouse-1} follow a link.
2436  * Fields::                 The @code{field} property defines  * Fields::                 The @code{field} property defines
2437                               fields within the buffer.                               fields within the buffer.
2438  * Not Intervals::          Why text properties do not use  * Not Intervals::          Why text properties do not use
# Line 3388  clickable pieces of text.  Also, the maj Line 3390  clickable pieces of text.  Also, the maj
3390  global definition) remains available for the rest of the text in the  global definition) remains available for the rest of the text in the
3391  buffer.  buffer.
3392    
3393    @node Enabling Mouse-1 to Follow Links
3394    @subsection Enabling Mouse-1 to Follow Links
3395    @cindex follow links
3396    
3397      Traditionally, Emacs uses a @key{mouse-1} click to set point and a
3398    @key{mouse-2} click to follow a link, whereas most other applications
3399    use a @key{mouse-1} click for both purposes, depending on whether you
3400    click outside or inside a link.
3401    
3402      Starting with Emacs release 21.4, the user visible behaviour of a
3403    @key{mouse-1} click on a link has been changed to match this
3404    context-sentitive dual behaviour.  The user can customize this
3405    behaviour through the variable @code{mouse-1-click-follows-link}.
3406    
3407      However, at the Lisp level, @key{mouse-2} is still used as the
3408    action for the clickable text corresponding to the link, and the
3409    clickable text must be explicitly marked as a link for a @key{mouse-1}
3410    click to follow the link.
3411    
3412      There are several methods that can be used to identify a clickable
3413    text as a link:
3414    
3415    @table @asis
3416    @item follow-link property
3417    
3418      If the clickable text has a non-nil @code{follow-link} text or overlay
3419    property, the value of that property determines what to do.
3420    
3421    @item follow-link event
3422    
3423      If there is a binding for the @code{follow-link} event, either on
3424    the clickable text or in the local keymap, the binding of that event
3425    determines whether the mouse click position is inside a link:
3426    
3427    @table @asis
3428    @item mouse-face
3429    
3430      If the binding is @code{mouse-face}, the mouse click position is
3431    inside a link if there is a non-nil @code{mouse-face} property at
3432    that position.  A value of @code{t} is used to determine what to do next.
3433    
3434    For example, here is how @key{mouse-1} are setup in info mode:
3435    
3436    @example
3437    (define-key Info-mode-map [follow-link] 'mouse-face)
3438    @end example
3439    
3440    @item a function
3441    
3442      If the binding is a function, @var{func}, the mouse click position,
3443    @var{pos}, is inside a link if the call @code{(@var{func} @var{pos})}
3444    returns non-@code{nil}.  The return value from that call determines
3445    what to do next.
3446    
3447    For example, here is how pcvs enables @key{mouse-1} on file names only:
3448    
3449    @example
3450    (define-key map [follow-link]
3451      (lambda (pos)
3452        (if (eq (get-char-property pos 'face) 'cvs-filename-face) t)))
3453    @end example
3454    
3455    @item anthing else
3456    
3457      If the binding is anything else, the binding determines what to do.
3458    @end table
3459    
3460    @end table
3461    
3462    @noindent
3463    The resulting value determined above is interpreted as follows:
3464    
3465    @table @asis
3466    @item a string
3467    
3468      If the value is a string, the @key{mouse-1} event is translated into
3469    the first character of the string, i.e. the action of the @key{mouse-1}
3470    click is the local or global binding of that character.
3471    
3472    @item a vector
3473    
3474      If the value is is a vector, the @key{mouse-1} event is translated
3475    into the first element of that vector, i.e. the action of the
3476    @key{mouse-1} click is the local or global binding of that event.
3477    
3478    @item anthing else
3479    
3480      For any other non-nil valule, the @key{mouse-1} event is translated
3481    into a @key{mouse-2} event at the same position.
3482    @end table
3483    
3484      To use @key{mouse-1} on a button defined with @code{define-button-type},
3485    give the button a @code{follow-link} property with a value as
3486    specified above to determine how to follow the link.
3487    
3488      To use @key{mouse-1} on a widget defined with @code{define-widget},
3489    give the widget a @code{:follow-link} property with a value
3490    as specified above to determine how to follow the link.
3491    
3492    @defun mouse-on-link-p pos
3493    @tindex mouse-on-link-p
3494    Return non-@code{nil} if @var{pos} is on a link in the current buffer.
3495    @end defun
3496    
3497  @node Fields  @node Fields
3498  @subsection Defining and Using Fields  @subsection Defining and Using Fields
3499  @cindex fields  @cindex fields

Legend:
Removed from v.1.82  
changed lines
  Added in v.1.83

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26