Mercurial > hg > xemacs-beta
comparison man/lispref/commands.texi @ 213:78f53ef88e17 r20-4b5
Import from CVS: tag r20-4b5
author | cvs |
---|---|
date | Mon, 13 Aug 2007 10:06:47 +0200 |
parents | e45d5e7c476e |
children | 7df0dd720c89 |
comparison
equal
deleted
inserted
replaced
212:d8688acf4c5b | 213:78f53ef88e17 |
---|---|
1307 objects. Many functions that return events take an event object as an | 1307 objects. Many functions that return events take an event object as an |
1308 argument and fill in the fields of this event; or they make accept | 1308 argument and fill in the fields of this event; or they make accept |
1309 either an event object or @code{nil}, creating the event object first in | 1309 either an event object or @code{nil}, creating the event object first in |
1310 the latter case. | 1310 the latter case. |
1311 | 1311 |
1312 @defun allocate-event | 1312 @defun make-event &optional type plist |
1313 This function returns an empty event structure. WARNING: The event | 1313 This function creates a new event structure. If no arguments are |
1314 object returned may be a reused one; see the function | 1314 specified, the created event will be empty. To specify the event type, |
1315 @code{deallocate-event}. | 1315 use the @var{type} argument. The allowed types are @code{empty}, |
1316 @code{key-press}, @code{button-press}, @code{button-release}, or | |
1317 @code{motion}. | |
1318 | |
1319 @var{plist} is a property list, the properties being compatible to those | |
1320 returned by @code{event-properties}. For events other than | |
1321 @code{empty}, it is mandatory to specify certain properties. For | |
1322 @code{empty} events, @var{plist} must be @code{nil}. The list is | |
1323 @dfn{canonicalized}, which means that if a property keyword is present | |
1324 more than once, only the first instance is taken into account. | |
1325 Specifying an unknown or illegal property signals an error. | |
1326 | |
1327 The following properties are allowed: | |
1328 | |
1329 @table @b | |
1330 @item @code{channel} | |
1331 The event channel. This is a frame or a console. For mouse events (of | |
1332 type @code{button-press}, @code{button-release} and @code{motion}), this | |
1333 must be a frame. For key-press events, it must be a console. If | |
1334 channel is unspecified by @var{plist}, it will be set to the selected | |
1335 frame or selected console, as appropriate. | |
1336 | |
1337 @item @code{key} | |
1338 The event key. This is either a symbol or a character. It is allowed | |
1339 (and required) only for key-press events. | |
1340 | |
1341 @item @code{button} | |
1342 The event button. This an integer, either 1, 2 or 3. It is allowed | |
1343 only for button-press and button-release events. | |
1344 | |
1345 @item @code{modifiers} | |
1346 The event modifiers. This is a list of modifier symbols. It is allowed | |
1347 for key-press, button-press, button-release and motion events. | |
1348 | |
1349 @item @code{x} | |
1350 The event X coordinate. This is an integer. It is relative to the | |
1351 channel's root window, and is allowed for button-press, button-release | |
1352 and motion events. | |
1353 | |
1354 @item @code{y} | |
1355 The event Y coordinate. This is an integer. It is relative to the | |
1356 channel's root window, and is allowed for button-press, button-release | |
1357 and motion events. This means that, for instance, to access the | |
1358 toolbar, the @code{y} property will have to be negative. | |
1359 | |
1360 @item @code{timestamp} | |
1361 The event timestamp, a non-negative integer. Allowed for all types of | |
1362 events. | |
1363 @end table | |
1364 | |
1365 @emph{WARNING}: the event object returned by this function may be a | |
1366 reused one; see the function @code{deallocate-event}. | |
1367 | |
1368 The events created by @code{make-event} can be used as non-interactive | |
1369 arguments to the functions with an @code{(interactive "e")} | |
1370 specification. | |
1371 | |
1372 Here are some basic examples of usage: | |
1373 | |
1374 @lisp | |
1375 @group | |
1376 ;; @r{Create an empty event.} | |
1377 (make-event) | |
1378 @result{} #<empty-event> | |
1379 @end group | |
1380 | |
1381 @group | |
1382 ;; @r{Try creating a key-press event.} | |
1383 (make-event 'key-press) | |
1384 @error{} Undefined key for keypress event | |
1385 @end group | |
1386 | |
1387 @group | |
1388 ;; @r{Creating a key-press event, try No. 2.} | |
1389 (make-event 'key-press '(key home)) | |
1390 @result{} #<keypress-event home> | |
1391 @end group | |
1392 | |
1393 @group | |
1394 ;; @r{Create a key-press event of dubious fame.} | |
1395 (make-event 'key-press '(key escape modifiers (meta alt control shift))) | |
1396 @result{} #<keypress-event control-meta-alt-shift-escape> | |
1397 @end group | |
1398 | |
1399 @group | |
1400 ;; @r{Create a M-button1 event at coordinates defined by variables | |
1401 ;; @var{x} and @var{y}.} | |
1402 (make-event 'button-press `(button 1 modifiers (meta) x ,x y ,y)) | |
1403 @result{} #<buttondown-event meta-button1> | |
1404 @end group | |
1405 | |
1406 @group | |
1407 ;; @r{Create a simmilar button-release event.} | |
1408 (make-event 'button-release `(button 1 modifiers (meta) x ,x y ,x)) | |
1409 @result{} #<buttonup-event meta-button1up> | |
1410 @end group | |
1411 | |
1412 @group | |
1413 ;; @r{Create a mouse-motion event.} | |
1414 (make-event 'motion '(x 20 y 30)) | |
1415 @result{} #<motion-event 20, 67> | |
1416 | |
1417 ;; @r{(the Y coordinate is printed incompatibly; however:)} | |
1418 (event-properties (make-event 'motion '(x 20 y 30))) | |
1419 @result{} (channel #<x-frame "emacs" 0x8e2> x 20 y 30 modifiers nil timestamp 0) | |
1420 @end group | |
1421 @end lisp | |
1422 | |
1423 In conjunction with @code{event-properties}, you can use | |
1424 @code{make-event} to create modified copies of existing events. For | |
1425 instance, the following code will return an @code{equal} copy of | |
1426 @var{event}: | |
1427 | |
1428 @lisp | |
1429 (make-event (event-type @var{event}) | |
1430 (event-properties @var{event})) | |
1431 @end lisp | |
1432 | |
1433 Note, however, that you cannot use @code{make-event} as the generic | |
1434 replacement for @code{copy-event}, because it does not allow creating | |
1435 all of the event types. | |
1436 | |
1437 To create a changed copy of an event, you can use the canonicalization | |
1438 feature of @var{plist}. The following example creates a copy of | |
1439 @var{event}, but with @code{modifiers} reset to @code{nil}. | |
1440 | |
1441 @lisp | |
1442 (make-event (event-type @var{event}) | |
1443 (append '(modifiers nil) | |
1444 (event-properties @var{event}))) | |
1445 @end lisp | |
1316 @end defun | 1446 @end defun |
1317 | 1447 |
1318 @defun copy-event event1 &optional event2 | 1448 @defun copy-event event1 &optional event2 |
1319 This function makes a copy of the given event object. If a second | 1449 This function makes a copy of the given event object. If a second |
1320 argument is given, the first event is copied into the second and the | 1450 argument is given, the first event is copied into the second and the |
1321 second is returned. If the second argument is not supplied (or is | 1451 second is returned. If the second argument is not supplied (or is |
1322 @code{nil}) then a new event will be made as with @code{allocate-event}. | 1452 @code{nil}) then a new event will be made. |
1323 @end defun | 1453 @end defun |
1324 | 1454 |
1325 @defun deallocate-event event | 1455 @defun deallocate-event event |
1326 This function allows the given event structure to be reused. You | 1456 This function allows the given event structure to be reused. You |
1327 @strong{MUST NOT} use this event object after calling this function with | 1457 @strong{MUST NOT} use this event object after calling this function with |