@@ -1332,7 +1332,7 @@ def __init__(self, name, canvas, guiEvent=None):
1332
1332
1333
1333
class LocationEvent (Event ):
1334
1334
"""
1335
- An event that has a screen location
1335
+ An event that has a screen location.
1336
1336
1337
1337
The following additional attributes are defined and shown with
1338
1338
their default values.
@@ -1356,28 +1356,23 @@ class LocationEvent(Event):
1356
1356
1357
1357
ydata : scalar
1358
1358
y coord of mouse in data coords
1359
-
1360
1359
"""
1361
- x = None # x position - pixels from left of canvas
1362
- y = None # y position - pixels from right of canvas
1363
- inaxes = None # the Axes instance if mouse us over axes
1364
- xdata = None # x coord of mouse in data coords
1365
- ydata = None # y coord of mouse in data coords
1366
1360
1367
- # the last event that was triggered before this one
1368
- lastevent = None
1361
+ lastevent = None # the last event that was triggered before this one
1369
1362
1370
1363
def __init__ (self , name , canvas , x , y , guiEvent = None ):
1371
1364
"""
1372
1365
*x*, *y* in figure coords, 0,0 = bottom, left
1373
1366
"""
1374
1367
Event .__init__ (self , name , canvas , guiEvent = guiEvent )
1375
- self .x = x
1376
- self .y = y
1368
+ self .x = x # x position - pixels from left of canvas
1369
+ self .y = y # y position - pixels from right of canvas
1370
+ self .inaxes = None # the Axes instance if mouse us over axes
1371
+ self .xdata = None # x coord of mouse in data coords
1372
+ self .ydata = None # y coord of mouse in data coords
1377
1373
1378
1374
if x is None or y is None :
1379
1375
# cannot check if event was in axes if no x,y info
1380
- self .inaxes = None
1381
1376
self ._update_enter_leave ()
1382
1377
return
1383
1378
@@ -1394,13 +1389,10 @@ def __init__(self, name, canvas, x, y, guiEvent=None):
1394
1389
trans = self .inaxes .transData .inverted ()
1395
1390
xdata , ydata = trans .transform_point ((x , y ))
1396
1391
except ValueError :
1397
- self .xdata = None
1398
- self .ydata = None
1392
+ pass
1399
1393
else :
1400
1394
self .xdata = xdata
1401
1395
self .ydata = ydata
1402
- else :
1403
- self .inaxes = None
1404
1396
1405
1397
self ._update_enter_leave ()
1406
1398
@@ -1443,18 +1435,21 @@ class MouseEvent(LocationEvent):
1443
1435
1444
1436
Attributes
1445
1437
----------
1446
- button : None, scalar, or str
1447
- button pressed None, 1, 2, 3, 'up', 'down' (up and down are used
1448
- for scroll events). Note that in the nbagg backend, both the
1449
- middle and right clicks return 3 since right clicking will bring
1450
- up the context menu in some browsers.
1438
+ button : { None, 1, 2, 3, 'up', 'down'}
1439
+ The button pressed. 'up' and 'down' are used for scroll events.
1440
+ Note that in the nbagg backend, both the middle and right clicks
1441
+ return 3 since right clicking will bring up the context menu in
1442
+ some browsers.
1451
1443
1452
- key : None, or str
1453
- the key depressed when the mouse event triggered (see
1454
- :class: `KeyEvent`)
1444
+ key : None or str
1445
+ The key pressed when the mouse event triggered, e.g. 'shift'.
1446
+ See `KeyEvent`.
1455
1447
1456
1448
step : scalar
1457
- number of scroll steps (positive for 'up', negative for 'down')
1449
+ The Number of scroll steps (positive for 'up', negative for 'down').
1450
+
1451
+ dblclick : bool
1452
+ *True* if the event is a double-click.
1458
1453
1459
1454
Examples
1460
1455
--------
@@ -1464,16 +1459,7 @@ def on_press(event):
1464
1459
print('you pressed', event.button, event.xdata, event.ydata)
1465
1460
1466
1461
cid = fig.canvas.mpl_connect('button_press_event', on_press)
1467
-
1468
1462
"""
1469
- x = None # x position - pixels from left of canvas
1470
- y = None # y position - pixels from right of canvas
1471
- button = None # button pressed None, 1, 2, 3
1472
- dblclick = None # whether or not the event is the result of a double click
1473
- inaxes = None # the Axes instance if mouse us over axes
1474
- xdata = None # x coord of mouse in data coords
1475
- ydata = None # y coord of mouse in data coords
1476
- step = None # scroll steps for scroll events
1477
1463
1478
1464
def __init__ (self , name , canvas , x , y , button = None , key = None ,
1479
1465
step = 0 , dblclick = False , guiEvent = None ):
0 commit comments