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