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:: |
* Links and Mouse-1:: How to make @key{Mouse-1} follow a link. |
|
How to make @key{mouse-1} follow a link. |
|
2435 |
* Fields:: The @code{field} property defines |
* Fields:: The @code{field} property defines |
2436 |
fields within the buffer. |
fields within the buffer. |
2437 |
* Not Intervals:: Why text properties do not use |
* Not Intervals:: Why text properties do not use |
3389 |
global definition) remains available for the rest of the text in the |
global definition) remains available for the rest of the text in the |
3390 |
buffer. |
buffer. |
3391 |
|
|
3392 |
@node Enabling Mouse-1 to Follow Links |
@node Links and Mouse-1 |
3393 |
@subsection Enabling Mouse-1 to Follow Links |
@subsection Links and Mouse-1 |
3394 |
@cindex follow links |
@cindex follow links |
3395 |
|
@cindex mouse-1 |
3396 |
|
|
3397 |
The normal Emacs command for activating text in read-only buffers is |
The normal Emacs command for activating text in read-only buffers is |
3398 |
@key{Mouse-2}, which includes following textual links. However, most |
@key{Mouse-2}, which includes following textual links. However, most |
3402 |
customize this behaviour through the variable |
customize this behaviour through the variable |
3403 |
@code{mouse-1-click-follows-link}. |
@code{mouse-1-click-follows-link}. |
3404 |
|
|
3405 |
To define text as a link at the Lisp level, you should bind |
To define text as a link at the Lisp level, you should bind the |
3406 |
@key{Mouse-2} to a command to follow the link. Then, to indicate |
@code{mouse-2} event to a command to follow the link. Then, to |
3407 |
that @key{Mouse-1} should also follow the link, here is what you do: |
indicate that @key{Mouse-1} should also follow the link, here is what |
3408 |
|
you do: |
3409 |
|
|
3410 |
@table @asis |
@table @asis |
3411 |
@item @code{follow-link} property |
@item @code{follow-link} property |
3480 |
To define @key{Mouse-1} to activate a button defined with |
To define @key{Mouse-1} to activate a button defined with |
3481 |
@code{define-button-type}, give the button a @code{follow-link} |
@code{define-button-type}, give the button a @code{follow-link} |
3482 |
property with a value as specified above to determine how to follow |
property with a value as specified above to determine how to follow |
3483 |
the link. |
the link. For example, here is how Help mode handles @key{Mouse-1}: |
3484 |
@c ??? That is not clear. This needs an example or an xref. |
|
3485 |
|
@smallexample |
3486 |
|
(define-button-type 'help-xref |
3487 |
|
'follow-link t |
3488 |
|
'action #'help-button-action) |
3489 |
|
@end smallexample |
3490 |
|
|
3491 |
To define @key{Mouse-1} on a widget defined with |
To define @key{Mouse-1} on a widget defined with |
3492 |
@code{define-widget}, give the widget a @code{:follow-link} property |
@code{define-widget}, give the widget a @code{:follow-link} property |
3493 |
with a value as specified above to determine how to follow the link. |
with a value as specified above to determine how to follow the link. |
3494 |
@c ??? That is not clear. This needs an example or an xref. |
|
3495 |
|
For example, here is how the @code{link} widget specifies that |
3496 |
|
a @key{Mouse-1} click shall be translated to @key{RET}: |
3497 |
|
|
3498 |
|
@smallexample |
3499 |
|
(define-widget 'link 'item |
3500 |
|
"An embedded link." |
3501 |
|
:button-prefix 'widget-link-prefix |
3502 |
|
:button-suffix 'widget-link-suffix |
3503 |
|
:follow-link "\C-m" |
3504 |
|
:help-echo "Follow the link." |
3505 |
|
:format "%[%t%]") |
3506 |
|
@end smallexample |
3507 |
|
|
3508 |
@defun mouse-on-link-p pos |
@defun mouse-on-link-p pos |
3509 |
@tindex mouse-on-link-p |
@tindex mouse-on-link-p |