]> ncurses.scripts.mit.edu Git - ncurses.git/blob - man/curs_mouse.3x
ncurses 4.1
[ncurses.git] / man / curs_mouse.3x
1 '\" t
2 .TH curs_mouse 3X ""
3 .SH NAME
4 \fBgetmouse\fR, \fBungetmouse\fR, 
5 \fBmousemask\fR - mouse interface through curses
6 .SH SYNOPSIS
7 .nf
8 \fB#include <curses.h>\fR
9
10 \fBtypedef unsigned long mmask_t;
11
12 typedef struct
13 {
14     short id;         \fI/* ID to distinguish multiple devices */\fB
15     int x, y, z;      \fI/* event coordinates */\fB
16     mmask_t bstate;   \fI/* button state bits */\fB
17 }
18 MEVENT;\fR
19 .fi
20 .br
21 \fBint getmouse(MEVENT *event);\fR
22 .br
23 \fBint ungetmouse(MEVENT *event);\fR
24 .br
25 \fBmmask_t mousemask(mmask_t newmask, mmask_t *oldmask);\fR
26 .br
27 \fBbool wenclose(WINDOW *win, int y, int x)\fR
28 .br
29 \fBint mouseinterval(int erval)\fR
30 .br
31 .SH DESCRIPTION
32 These functions provide an interface to mouse events from
33 \fBncurses\fR(3x).  Mouse events are represented by \fBKEY_MOUSE\fR
34 pseudo-key values in the \fBwgetch\fR input stream.
35
36 To make mouse events visible, use the \fBmousemask\fR function.  This will set
37 the mouse events to be reported.  By default, no mouse events are reported.
38 The function will return a mask to indicate which of the specified mouse events
39 can be reported; on complete failure it returns 0.  If oldmask is non-NULL,
40 this function fills the indicated location with the previous value of the given
41 window's mouse event mask.
42
43 As a side effect, setting a zero mousemask may turn off the mouse pointer;
44 setting a nonzero mask may turn it on.  Whether this happens is
45 device-dependent.
46
47 Here are the mouse event type masks:
48
49 .TS
50 l l
51 _ _
52 l l.
53 \fIName\fR      \fIDescription\fR
54 BUTTON1_PRESSED         mouse button 1 down 
55 BUTTON1_RELEASED        mouse button 1 up 
56 BUTTON1_CLICKED         mouse button 1 clicked
57 BUTTON1_DOUBLE_CLICKED  mouse button 1 double clicked
58 BUTTON1_TRIPLE_CLICKED  mouse button 1 triple clicked
59 BUTTON2_PRESSED         mouse button 2 down 
60 BUTTON2_RELEASED        mouse button 2 up 
61 BUTTON2_CLICKED         mouse button 2 clicked
62 BUTTON2_DOUBLE_CLICKED  mouse button 2 double clicked
63 BUTTON2_TRIPLE_CLICKED  mouse button 2 triple clicked
64 BUTTON3_PRESSED         mouse button 3 down 
65 BUTTON3_RELEASED        mouse button 3 up 
66 BUTTON3_CLICKED         mouse button 3 clicked
67 BUTTON3_DOUBLE_CLICKED  mouse button 3 double clicked
68 BUTTON3_TRIPLE_CLICKED  mouse button 3 triple clicked
69 BUTTON4_PRESSED         mouse button 4 down 
70 BUTTON4_RELEASED        mouse button 4 up 
71 BUTTON4_CLICKED         mouse button 4 clicked
72 BUTTON4_DOUBLE_CLICKED  mouse button 4 double clicked
73 BUTTON4_TRIPLE_CLICKED  mouse button 4 triple clicked
74 BUTTON_SHIFT    shift was down during button state change
75 BUTTON_CTRL     control was down during button state change
76 BUTTON_ALT      alt was down during button state change
77 ALL_MOUSE_EVENTS        report all button state changes
78 REPORT_MOUSE_POSITION   report mouse movement
79 .TE
80
81 Once a class of mouse events have been made visible in a window,
82 calling the \fBwgetch\fR function on that window may return
83 \fBKEY_MOUSE\fR as an indicator that a mouse event has been queued.
84 To read the event data and pop the event off the queue, call
85 \fBgetmouse\fR.  This function will return \fBOK\fR if a mouse event
86 is actually visible in the given window, \fBERR\fR otherwise.
87 When \fBgetmouse\fR returns \fBOK\fR, the data deposited as y and
88 x in the event structure coordinates will be screen-relative character-cell
89 coordinates.  The returned state mask will have exactly one bit set to
90 indicate the event type.
91
92 The \fBungetmouse\fR function behaves analogously to \fBungetch\fR.  It pushes
93 a \fBKEY_MOUSE\fR event onto the input queue, and associates with that event
94 the given state data and screen-relative character-cell coordinates.
95
96 The \fBwenclose\fR function tests whether a given pair of screen-relative
97 character-cell coordinates is enclosed by a given window, returning TRUE
98 if it is and FALSE otherwise.  It is useful for determining what subset of
99 the screen windows enclose the location of a mouse event.
100
101 The \fBmouseinterval\fR function sets the maximum time (in thousands of a
102 second) that can elapse between press and release events in order for them to
103 be recognized as a click.  This function returns the previous interval value.
104 The default is one fifth of a second.
105
106 Note that mouse events will be ignored when input is in cooked mode, and will
107 cause an error beep when cooked mode is being simulated in a window by a
108 function such as \fBgetstr\fR that expects a linefeed for input-loop
109 termination.
110
111 .SH RETURN VALUE
112 All routines return the integer \fBERR\fR upon failure or \fBOK\fR
113 upon successful completion.
114 .SH PORTABILITY
115 These calls were designed for \fBncurses\fR(3x), and are not found in SVr4
116 curses, 4.4BSD curses, or any other previous version of curses.
117
118 The feature macro \fBNCURSES_MOUSE_VERSION\fR is provided so the preprocessor
119 can be used to test whether these features are present (its value is 1).  NOTE:
120 THIS INTERFACE IS EXPERIMENTAL AND IS SUBJECT TO CHANGE WITHOUT NOTICE!  If the
121 interface is changed, the value of \fBNCURSES_MOUSE_VERSION\fR will be
122 incremented.
123
124 The order of the \fBMEVENT\fR structure members is not guaranteed.  
125 Additional fields may be added to the structure in the future.
126
127 Under \fBncurses\fR(3x), these calls are implemented using either
128 xterm's built-in mouse-tracking API or Alessandro Rubini's gpm server.
129 If you are using something other than xterm there is no gpm daemon
130 running on your machine, mouse events will not be visible to
131 \fBncurses\fR(3x) (and the \fBwmousemask\fR function will always
132 return \fB0\fR).
133
134 The z member in the event structure is not presently used.  It is intended
135 for use with touch screens (which may be pressure-sensitive) or with
136 3D-mice/trackballs/power gloves.
137 .SH BUGS
138 Mouse events under xterm will not in fact be ignored during cooked mode,
139 if they have been enabled by \fBwmousemask\fR.  Instead, the xterm mouse
140 report sequence will appear in the string read.
141
142 Mouse events under xterm will not be detected correctly in a window with
143 its keypad bit off.
144 .SH SEE ALSO
145 \fBcurses\fR(3X).
146 .\"#
147 .\"# The following sets edit modes for GNU EMACS
148 .\"# Local Variables:
149 .\"# mode:nroff
150 .\"# fill-column:79
151 .\"# End: