comparison man/lispref/commands.texi @ 149:538048ae2ab8 r20-3b1

Import from CVS: tag r20-3b1
author cvs
date Mon, 13 Aug 2007 09:36:16 +0200
parents 131b0175ea99
children 169c0442b401
comparison
equal deleted inserted replaced
148:f659db2a1f73 149:538048ae2ab8
721 @end group 721 @end group
722 @end example 722 @end example
723 @end defvar 723 @end defvar
724 724
725 @defvar last-command-char 725 @defvar last-command-char
726
726 If the value of @code{last-command-event} is a keyboard event, then this 727 If the value of @code{last-command-event} is a keyboard event, then this
727 is the nearest @sc{ASCII} equivalent to it. This is the value that 728 is the nearest character equivalent to it (or @code{nil} if there is no
728 @code{self-insert-command} will put in the buffer. Remember that there 729 character equivalent). @code{last-command-char} is the character that
729 is @emph{not} a 1:1 mapping between keyboard events and @sc{ASCII} 730 @code{self-insert-command} will insert in the buffer. Remember that
730 characters: the set of keyboard events is much larger, so writing code 731 there is @emph{not} a one-to-one mapping between keyboard events and
731 that examines this variable to determine what key has been typed is bad 732 XEmacs characters: many keyboard events have no corresponding character,
732 practice, unless you are certain that it will be one of a small set of 733 and when the Mule feature is available, most characters can not be input
733 characters. 734 on standard keyboards, except possibly with help from an input method.
734 735 So writing code that examines this variable to determine what key has
735 This function exists for compatibility with Emacs version 18. 736 been typed is bad practice, unless you are certain that it will be one
737 of a small set of characters.
738
739 This variable exists for compatibility with Emacs version 18.
736 740
737 @example 741 @example
738 @group 742 @group
739 last-command-char 743 last-command-char
740 ;; @r{Now use @kbd{C-u C-x C-e} to evaluate that.} 744 ;; @r{Now use @kbd{C-u C-x C-e} to evaluate that.}
741 @result{} 5 745 @result{} ?\^E
742 @end group 746 @end group
743 @end example 747 @end example
744 748
745 @noindent
746 The value is 5 because that is the @sc{ASCII} code for @kbd{C-e}.
747 @end defvar 749 @end defvar
748 750
749 @defvar current-mouse-event 751 @defvar current-mouse-event
750 This variable holds the mouse-button event which invoked this command, 752 This variable holds the mouse-button event which invoked this command,
751 or @code{nil}. This is what @code{(interactive "e")} returns. 753 or @code{nil}. This is what @code{(interactive "e")} returns.
818 @itemx button-release event 820 @itemx button-release event
819 A button was pressed or released. Along with the button that was pressed 821 A button was pressed or released. Along with the button that was pressed
820 or released, button events specify the modifier keys that were held down 822 or released, button events specify the modifier keys that were held down
821 at the time and the position of the pointer at the time. 823 at the time and the position of the pointer at the time.
822 824
823 @item pointer-motion event 825 @item motion event
824 The pointer was moved. Along with the position of the pointer, these events 826 The pointer was moved. Along with the position of the pointer, these events
825 also specify the modifier keys that were held down at the time. 827 also specify the modifier keys that were held down at the time.
826 828
827 @item misc-user event 829 @item misc-user event
828 A menu item was selected, or the scrollbar was used. 830 A menu item was selected, or the scrollbar was used.
952 The object to pass to the function. The function and object are set 954 The object to pass to the function. The function and object are set
953 when the event is created. 955 when the event is created.
954 @end table 956 @end table
955 @end table 957 @end table
956 958
959 @defun event-type event
960 Return the type of @var{event}.
961
962 This will be a symbol; one of
963
964 @table @code
965 @item key-press
966 A key was pressed.
967 @item button-press
968 A mouse button was pressed.
969 @item button-release
970 A mouse button was released.
971 @item motion
972 The mouse moved.
973 @item misc-user
974 Some other user action happened; typically, this is
975 a menu selection or scrollbar action.
976 @item process
977 Input is available from a subprocess.
978 @item timeout
979 A timeout has expired.
980 @item eval
981 This causes a specified action to occur when dispatched.
982 @item magic
983 Some window-system-specific event has occurred.
984 @end table
985 @end defun
986
957 @node Event Predicates 987 @node Event Predicates
958 @subsection Event Predicates 988 @subsection Event Predicates
959 989
960 The following predicates return whether an object is an event of a particular 990 The following predicates return whether an object is an event of a
961 type. 991 particular type.
962
963 @defun button-event-p object object
964 This is true if @var{object} is a button-press or button-release event.
965 @end defun
966
967 @defun button-press-event-p object
968 This is true if @var{object} is a mouse-button-press event.
969 @end defun
970
971 @defun button-release-event-p object
972 This is true if @var{object} is a mouse-button-release event.
973 @end defun
974
975 @defun eval-event-p object
976 This is true if @var{object} is an eval or misc-user event.
977 @end defun
978 992
979 @defun key-press-event-p object 993 @defun key-press-event-p object
980 This is true if @var{object} is a key-press event. 994 This is true if @var{object} is a key-press event.
981 @end defun 995 @end defun
982 996
997 @defun button-event-p object object
998 This is true if @var{object} is a mouse button-press or button-release
999 event.
1000 @end defun
1001
1002 @defun button-press-event-p object
1003 This is true if @var{object} is a mouse button-press event.
1004 @end defun
1005
1006 @defun button-release-event-p object
1007 This is true if @var{object} is a mouse button-release event.
1008 @end defun
1009
1010 @defun motion-event-p object
1011 This is true if @var{object} is a mouse motion event.
1012 @end defun
1013
1014 @defun mouse-event-p object
1015 This is true if @var{object} is a mouse button-press, button-release
1016 or motion event.
1017 @end defun
1018
1019 @defun eval-event-p object
1020 This is true if @var{object} is an eval event.
1021 @end defun
1022
983 @defun misc-user-event-p object 1023 @defun misc-user-event-p object
984 This is true if @var{object} is a misc-user event. 1024 This is true if @var{object} is a misc-user event.
985 @end defun 1025 @end defun
986 1026
987 @defun motion-event-p object
988 This is true if @var{object} is a mouse-motion event.
989 @end defun
990
991 @defun process-event-p object 1027 @defun process-event-p object
992 This is true if @var{object} is a process event. 1028 This is true if @var{object} is a process event.
993 @end defun 1029 @end defun
994 1030
995 @defun timeout-event-p object 1031 @defun timeout-event-p object
1001 @end defun 1037 @end defun
1002 1038
1003 @node Accessing Mouse Event Positions 1039 @node Accessing Mouse Event Positions
1004 @subsection Accessing the Position of a Mouse Event 1040 @subsection Accessing the Position of a Mouse Event
1005 1041
1006 Unlike other events, mouse events (i.e. mouse-motion, button-press, and 1042 Unlike other events, mouse events (i.e. motion, button-press, and
1007 button-release events) occur in a particular location on the screen. 1043 button-release events) occur in a particular location on the screen.
1008 Many primitives are provided for determining exactly where the event 1044 Many primitives are provided for determining exactly where the event
1009 occurred and what is under that location. 1045 occurred and what is under that location.
1010 1046
1011 @menu 1047 @menu
1030 @end defun 1066 @end defun
1031 1067
1032 @defun event-x-pixel event 1068 @defun event-x-pixel event
1033 This function returns the X position in pixels of the given mouse event. 1069 This function returns the X position in pixels of the given mouse event.
1034 The value returned is relative to the frame the event occurred in. 1070 The value returned is relative to the frame the event occurred in.
1035 This will signal an error if the event is not a mouse-motion, button-press, 1071 This will signal an error if the event is not a mouse event.
1036 or button-release event.
1037 @end defun 1072 @end defun
1038 1073
1039 @defun event-y-pixel event 1074 @defun event-y-pixel event
1040 This function returns the Y position in pixels of the given mouse event. 1075 This function returns the Y position in pixels of the given mouse event.
1041 The value returned is relative to the frame the event occurred in. 1076 The value returned is relative to the frame the event occurred in.
1042 This will signal an error if the event is not a mouse-motion, button-press, 1077 This will signal an error if the event is not a mouse event.
1043 or button-release event.
1044 @end defun 1078 @end defun
1045 1079
1046 @node Window-Level Event Position Info 1080 @node Window-Level Event Position Info
1047 @subsubsection Window-Level Event Position Info 1081 @subsubsection Window-Level Event Position Info
1048 1082
1051 1085
1052 @defun event-window event 1086 @defun event-window event
1053 Given a mouse motion, button press, or button release event, compute and 1087 Given a mouse motion, button press, or button release event, compute and
1054 return the window on which that event occurred. This may be @code{nil} 1088 return the window on which that event occurred. This may be @code{nil}
1055 if the event occurred in the border or over a toolbar. The modeline is 1089 if the event occurred in the border or over a toolbar. The modeline is
1056 considered to be in the window it represents. 1090 considered to be within the window it describes.
1057 @end defun 1091 @end defun
1058 1092
1059 @defun event-buffer event 1093 @defun event-buffer event
1060 Given a mouse motion, button press, or button release event, compute and 1094 Given a mouse motion, button press, or button release event, compute and
1061 return the buffer of the window on which that event occurred. This may 1095 return the buffer of the window on which that event occurred. This may
1062 be @code{nil} if the event occurred in the border or over a toolbar. 1096 be @code{nil} if the event occurred in the border or over a toolbar.
1063 The modeline is considered to be in the window it represents. This is 1097 The modeline is considered to be within the window it describes. This is
1064 equivalent to calling @code{event-window} and then calling 1098 equivalent to calling @code{event-window} and then calling
1065 @code{event-buffer} on the result if it is a window. 1099 @code{window-buffer} on the result if it is a window.
1066 @end defun 1100 @end defun
1067 1101
1068 @defun event-window-x-pixel event 1102 @defun event-window-x-pixel event
1069 This function returns the X position in pixels of the given mouse event. 1103 This function returns the X position in pixels of the given mouse event.
1070 The value returned is relative to the window the event occurred in. 1104 The value returned is relative to the window the event occurred in.
1204 This function returns the Keysym of the given key-press event. 1238 This function returns the Keysym of the given key-press event.
1205 This will be the @sc{ASCII} code of a printing character, or a symbol. 1239 This will be the @sc{ASCII} code of a printing character, or a symbol.
1206 @end defun 1240 @end defun
1207 1241
1208 @defun event-button event 1242 @defun event-button event
1209 This function returns the button-number of the given mouse-button-press 1243 This function returns the button-number of the given button-press or
1210 event. 1244 button-release event.
1211 @end defun 1245 @end defun
1212 1246
1213 @defun event-modifiers event 1247 @defun event-modifiers event
1214 This function returns a list of symbols, the names of the modifier keys 1248 This function returns a list of symbols, the names of the modifier keys
1215 which were down when the given mouse or keyboard event was produced. 1249 which were down when the given mouse or keyboard event was produced.