1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843
|
.. wxPython Phoenix documentation
This file was generated by Phoenix's sphinx generator and associated
tools, do not edit by hand.
Copyright: (c) 2011-2018 by Total Control Software
License: wxWindows License
.. include:: headings.inc
.. _wx.MouseEvent:
==========================================================================================================================================
|phoenix_title| **wx.MouseEvent**
==========================================================================================================================================
This event class contains information about the events generated by the mouse: they include mouse buttons press and release events and mouse move events.
All mouse events involving the buttons use ``MOUSE_BTN_LEFT`` for the left mouse button, ``MOUSE_BTN_MIDDLE`` for the middle one and ``MOUSE_BTN_RIGHT`` for the right one. And if the system supports more buttons, the ``MOUSE_BTN_AUX1`` and ``MOUSE_BTN_AUX2`` events can also be generated. Note that not all mice have even a middle button so a portable application should avoid relying on the events from it (but the right button click can be emulated using the left mouse button with the control key under Mac platforms with a single button mouse).
For the ``wxEVT_ENTER_WINDOW`` and ``wxEVT_LEAVE_WINDOW`` events purposes, the mouse is considered to be inside the window if it is in the window client area and not inside one of its children. In other words, the parent window receives ``wxEVT_LEAVE_WINDOW`` event not only when the mouse leaves the window entirely but also when it enters one of its children.
The position associated with a mouse event is expressed in the window coordinates of the window which generated the event, you can use :meth:`wx.Window.ClientToScreen` to convert it to screen coordinates and possibly call :meth:`wx.Window.ScreenToClient` next to convert it to window coordinates of another window.
.. _MouseEvent-events:
|events| Events Emitted by this Class
=====================================
Handlers bound for the following event types will receive a :ref:`wx.MouseEvent` parameter.
Event macros:
- EVT_LEFT_DOWN: Process a ``wxEVT_LEFT_DOWN`` event. The handler of this event should normally call event.Skip() to allow the default processing to take place as otherwise the window under mouse wouldn't get the focus.
- EVT_LEFT_UP: Process a ``wxEVT_LEFT_UP`` event.
- EVT_LEFT_DCLICK: Process a ``wxEVT_LEFT_DCLICK`` event.
- EVT_MIDDLE_DOWN: Process a ``wxEVT_MIDDLE_DOWN`` event.
- EVT_MIDDLE_UP: Process a ``wxEVT_MIDDLE_UP`` event.
- EVT_MIDDLE_DCLICK: Process a ``wxEVT_MIDDLE_DCLICK`` event.
- EVT_RIGHT_DOWN: Process a ``wxEVT_RIGHT_DOWN`` event.
- EVT_RIGHT_UP: Process a ``wxEVT_RIGHT_UP`` event.
- EVT_RIGHT_DCLICK: Process a ``wxEVT_RIGHT_DCLICK`` event.
- EVT_MOUSE_AUX1_DOWN: Process a ``wxEVT_AUX1_DOWN`` event.
- EVT_MOUSE_AUX1_UP: Process a ``wxEVT_AUX1_UP`` event.
- EVT_MOUSE_AUX1_DCLICK: Process a ``wxEVT_AUX1_DCLICK`` event.
- EVT_MOUSE_AUX2_DOWN: Process a ``wxEVT_AUX2_DOWN`` event.
- EVT_MOUSE_AUX2_UP: Process a ``wxEVT_AUX2_UP`` event.
- EVT_MOUSE_AUX2_DCLICK: Process a ``wxEVT_AUX2_DCLICK`` event.
- EVT_MOTION: Process a ``wxEVT_MOTION`` event.
- EVT_ENTER_WINDOW: Process a ``wxEVT_ENTER_WINDOW`` event.
- EVT_LEAVE_WINDOW: Process a ``wxEVT_LEAVE_WINDOW`` event.
- EVT_MOUSEWHEEL: Process a ``wxEVT_MOUSEWHEEL`` event.
- EVT_MOUSE_EVENTS: Process all mouse events.
.. note::
Note that under Windows ``CE`` mouse enter and leave events are not natively supported by the system but are generated by wxWidgets itself. This has several drawbacks: the ``LEAVE_WINDOW`` event might be received some time after the mouse left the window and the state variables for it may have changed during this time.
.. note::
Note the difference between methods like :meth:`wx.MouseEvent.LeftDown` and the inherited :meth:`wx.MouseState.LeftIsDown` : the former returns ``True`` when the event corresponds to the left mouse button click while the latter returns ``True`` if the left mouse button is currently being pressed. For example, when the user is dragging the mouse you can use :meth:`wx.MouseEvent.LeftIsDown` to test whether the left mouse button is (still) depressed. Also, by convention, if :meth:`wx.MouseEvent.LeftDown` returns ``True``, :meth:`wx.MouseEvent.LeftIsDown` will also return ``True`` in wxWidgets whatever the underlying GUI behaviour is (which is platform-dependent). The same applies, of course, to other mouse buttons as well.
.. seealso:: :ref:`wx.KeyEvent`
|
|class_hierarchy| Class Hierarchy
=================================
.. raw:: html
<div id="toggleBlock" onclick="return toggleVisibility(this)" class="closed" style="cursor:pointer;">
<img id="toggleBlock-trigger" src="_static/images/closed.png"/>
Inheritance diagram for class <strong>MouseEvent</strong>:
</div>
<div id="toggleBlock-summary" style="display:block;"></div>
<div id="toggleBlock-content" style="display:none;">
<p class="graphviz">
<center><img src="_static/images/inheritance/wx.MouseEvent_inheritance.png" alt="Inheritance diagram of MouseEvent" usemap="#dummy" class="inheritance"/></center>
</div>
<script type="text/javascript">toggleVisibilityOnLoad(document.getElementById('toggleBlock'))</script>
<map id="dummy" name="dummy"> <area shape="rect" id="node1" href="wx.Event.html" title="wx.Event" alt="" coords="165,83,243,112"/> <area shape="rect" id="node5" href="wx.MouseEvent.html" title="wx.MouseEvent" alt="" coords="80,160,200,189"/> <area shape="rect" id="node2" href="wx.Object.html" title="wx.Object" alt="" coords="165,5,247,35"/> <area shape="rect" id="node3" href="wx.MouseState.html" title="wx.MouseState" alt="" coords="17,83,135,112"/> <area shape="rect" id="node4" href="wx.KeyboardState.html" title="wx.KeyboardState" alt="" coords="5,5,140,35"/> </map>
</p>
|
|method_summary| Methods Summary
================================
================================================================================ ================================================================================
:meth:`~wx.MouseEvent.__init__` Constructor.
:meth:`~wx.MouseEvent.Aux1DClick` Returns ``True`` if the event was a first extra button double click.
:meth:`~wx.MouseEvent.Aux1Down` Returns ``True`` if the first extra button mouse button changed to down.
:meth:`~wx.MouseEvent.Aux1Up` Returns ``True`` if the first extra button mouse button changed to up.
:meth:`~wx.MouseEvent.Aux2DClick` Returns ``True`` if the event was a second extra button double click.
:meth:`~wx.MouseEvent.Aux2Down` Returns ``True`` if the second extra button mouse button changed to down.
:meth:`~wx.MouseEvent.Aux2Up` Returns ``True`` if the second extra button mouse button changed to up.
:meth:`~wx.MouseEvent.Button` Returns ``True`` if the event was generated by the specified button.
:meth:`~wx.MouseEvent.ButtonDClick` If the argument is omitted, this returns ``True`` if the event was a mouse double click event.
:meth:`~wx.MouseEvent.ButtonDown` If the argument is omitted, this returns ``True`` if the event was a mouse button down event.
:meth:`~wx.MouseEvent.ButtonUp` If the argument is omitted, this returns ``True`` if the event was a mouse button up event.
:meth:`~wx.MouseEvent.Dragging` Returns ``True`` if this was a dragging event (motion while a button is depressed).
:meth:`~wx.MouseEvent.Entering` Returns ``True`` if the mouse was entering the window.
:meth:`~wx.MouseEvent.GetButton` Returns the mouse button which generated this event or ``MOUSE_BTN_NONE`` if no button is involved (for mouse move, enter or leave event, for example).
:meth:`~wx.MouseEvent.GetClickCount` Returns the number of mouse clicks for this event: 1 for a simple click, 2 for a double-click, 3 for a triple-click and so on.
:meth:`~wx.MouseEvent.GetColumnsPerAction` Returns the configured number of columns (or whatever) to be scrolled per wheel action.
:meth:`~wx.MouseEvent.GetLinesPerAction` Returns the configured number of lines (or whatever) to be scrolled per wheel action.
:meth:`~wx.MouseEvent.GetLogicalPosition` Returns the logical mouse position in pixels (i.e. translated according to the translation set for the DC, which usually indicates that the window has been scrolled).
:meth:`~wx.MouseEvent.GetWheelAxis` Gets the axis the wheel operation concerns.
:meth:`~wx.MouseEvent.GetWheelDelta` Get wheel delta, normally 120.
:meth:`~wx.MouseEvent.GetWheelRotation` Get wheel rotation, positive or negative indicates direction of rotation.
:meth:`~wx.MouseEvent.IsButton` Returns ``True`` if the event was a mouse button event (not necessarily a button down event - that may be tested using :meth:`~MouseEvent.ButtonDown` ).
:meth:`~wx.MouseEvent.IsPageScroll` Returns ``True`` if the system has been setup to do page scrolling with the mouse wheel instead of line scrolling.
:meth:`~wx.MouseEvent.Leaving` Returns ``True`` if the mouse was leaving the window.
:meth:`~wx.MouseEvent.LeftDClick` Returns ``True`` if the event was a left double click.
:meth:`~wx.MouseEvent.LeftDown` Returns ``True`` if the left mouse button changed to down.
:meth:`~wx.MouseEvent.LeftUp` Returns ``True`` if the left mouse button changed to up.
:meth:`~wx.MouseEvent.MetaDown` Returns ``True`` if the Meta key was down at the time of the event.
:meth:`~wx.MouseEvent.MiddleDClick` Returns ``True`` if the event was a middle double click.
:meth:`~wx.MouseEvent.MiddleDown` Returns ``True`` if the middle mouse button changed to down.
:meth:`~wx.MouseEvent.MiddleUp` Returns ``True`` if the middle mouse button changed to up.
:meth:`~wx.MouseEvent.Moving` Returns ``True`` if this was a motion event and no mouse buttons were pressed.
:meth:`~wx.MouseEvent.RightDClick` Returns ``True`` if the event was a right double click.
:meth:`~wx.MouseEvent.RightDown` Returns ``True`` if the right mouse button changed to down.
:meth:`~wx.MouseEvent.RightUp` Returns ``True`` if the right mouse button changed to up.
================================================================================ ================================================================================
|
|property_summary| Properties Summary
=====================================
================================================================================ ================================================================================
:attr:`~wx.MouseEvent.LinesPerAction` See :meth:`~wx.MouseEvent.GetLinesPerAction`
:attr:`~wx.MouseEvent.LogicalPosition` See :meth:`~wx.MouseEvent.GetLogicalPosition`
:attr:`~wx.MouseEvent.WheelDelta` See :meth:`~wx.MouseEvent.GetWheelDelta`
:attr:`~wx.MouseEvent.WheelRotation` See :meth:`~wx.MouseEvent.GetWheelRotation`
================================================================================ ================================================================================
|
|api| Class API
===============
.. class:: wx.MouseEvent(Event, MouseState)
**Possible constructors**::
MouseEvent(mouseEventType=wxEVT_NULL)
This event class contains information about the events generated by
the mouse: they include mouse buttons press and release events and
mouse move events.
.. method:: __init__(self, mouseEventType=wxEVT_NULL)
Constructor.
Valid event types are:
- ``wxEVT_ENTER_WINDOW``
- ``wxEVT_LEAVE_WINDOW``
- ``wxEVT_LEFT_DOWN``
- ``wxEVT_LEFT_UP``
- ``wxEVT_LEFT_DCLICK``
- ``wxEVT_MIDDLE_DOWN``
- ``wxEVT_MIDDLE_UP``
- ``wxEVT_MIDDLE_DCLICK``
- ``wxEVT_RIGHT_DOWN``
- ``wxEVT_RIGHT_UP``
- ``wxEVT_RIGHT_DCLICK``
- ``wxEVT_AUX1_DOWN``
- ``wxEVT_AUX1_UP``
- ``wxEVT_AUX1_DCLICK``
- ``wxEVT_AUX2_DOWN``
- ``wxEVT_AUX2_UP``
- ``wxEVT_AUX2_DCLICK``
- ``wxEVT_MOTION``
- ``wxEVT_MOUSEWHEEL``
:param `mouseEventType`:
:type `mouseEventType`: wx.EventType
.. method:: Aux1DClick(self)
Returns ``True`` if the event was a first extra button double click.
:rtype: `bool`
.. method:: Aux1Down(self)
Returns ``True`` if the first extra button mouse button changed to down.
:rtype: `bool`
.. method:: Aux1Up(self)
Returns ``True`` if the first extra button mouse button changed to up.
:rtype: `bool`
.. method:: Aux2DClick(self)
Returns ``True`` if the event was a second extra button double click.
:rtype: `bool`
.. method:: Aux2Down(self)
Returns ``True`` if the second extra button mouse button changed to down.
:rtype: `bool`
.. method:: Aux2Up(self)
Returns ``True`` if the second extra button mouse button changed to up.
:rtype: `bool`
.. method:: Button(self, but)
Returns ``True`` if the event was generated by the specified button.
:param `but`:
:type `but`: wx.MouseButton
:rtype: `bool`
.. seealso:: `MouseState.ButtoinIsDown()`
.. method:: ButtonDClick(self, but=MOUSE_BTN_ANY)
If the argument is omitted, this returns ``True`` if the event was a mouse double click event.
Otherwise the argument specifies which double click event was generated (see :ref:`wx.Button` for the possible values).
:param `but`:
:type `but`: wx.MouseButton
:rtype: `bool`
.. method:: ButtonDown(self, but=MOUSE_BTN_ANY)
If the argument is omitted, this returns ``True`` if the event was a mouse button down event.
Otherwise the argument specifies which button-down event was generated (see :ref:`wx.Button` for the possible values).
:param `but`:
:type `but`: wx.MouseButton
:rtype: `bool`
.. method:: ButtonUp(self, but=MOUSE_BTN_ANY)
If the argument is omitted, this returns ``True`` if the event was a mouse button up event.
Otherwise the argument specifies which button-up event was generated (see :ref:`wx.Button` for the possible values).
:param `but`:
:type `but`: wx.MouseButton
:rtype: `bool`
.. method:: Dragging(self)
Returns ``True`` if this was a dragging event (motion while a button is depressed).
:rtype: `bool`
.. seealso:: :meth:`Moving`
.. method:: Entering(self)
Returns ``True`` if the mouse was entering the window.
:rtype: `bool`
.. seealso:: :meth:`Leaving`
.. method:: GetButton(self)
Returns the mouse button which generated this event or ``MOUSE_BTN_NONE`` if no button is involved (for mouse move, enter or leave event, for example).
Otherwise ``MOUSE_BTN_LEFT`` is returned for the left button down, up and double click events, ``MOUSE_BTN_MIDDLE`` and ``MOUSE_BTN_RIGHT`` for the same events for the middle and the right buttons respectively.
:rtype: `int`
.. method:: GetClickCount(self)
Returns the number of mouse clicks for this event: 1 for a simple click, 2 for a double-click, 3 for a triple-click and so on.
Currently this function is implemented only in Mac and returns -1 for the other platforms (you can still distinguish simple clicks from double-clicks as they generate different kinds of events however).
:rtype: `int`
.. versionadded:: 2.9.0
.. method:: GetColumnsPerAction(self)
Returns the configured number of columns (or whatever) to be scrolled per wheel action.
Default value under most platforms is three.
:rtype: `int`
.. versionadded:: 2.9.5
.. seealso:: :meth:`GetLinesPerAction`
.. method:: GetLinesPerAction(self)
Returns the configured number of lines (or whatever) to be scrolled per wheel action.
Default value under most platforms is three.
:rtype: `int`
.. seealso:: :meth:`GetColumnsPerAction`
.. method:: GetLogicalPosition(self, dc)
Returns the logical mouse position in pixels (i.e. translated according to the translation set for the DC, which usually indicates that the window has been scrolled).
:param `dc`:
:type `dc`: wx.DC
:rtype: :ref:`wx.Point`
.. method:: GetWheelAxis(self)
Gets the axis the wheel operation concerns.
Usually the mouse wheel is used to scroll vertically so ``MOUSE_WHEEL_VERTICAL`` is returned but some mice (and most trackpads) also allow to use the wheel to scroll horizontally in which case ``MOUSE_WHEEL_HORIZONTAL`` is returned.
Notice that before wxWidgets 2.9.4 this method returned ``int`` .
:rtype: :ref:`wx.MouseWheelAxis`
.. method:: GetWheelDelta(self)
Get wheel delta, normally 120.
This is the threshold for action to be taken, and one such action (for example, scrolling one increment) should occur for each delta.
:rtype: `int`
.. method:: GetWheelRotation(self)
Get wheel rotation, positive or negative indicates direction of rotation.
Current devices all send an event when rotation is at least +/-WheelDelta, but finer resolution devices can be created in the future.
Because of this you shouldn't assume that one event is equal to 1 line, but you should be able to either do partial line scrolling or wait until several events accumulate before scrolling.
:rtype: `int`
.. method:: IsButton(self)
Returns ``True`` if the event was a mouse button event (not necessarily a button down event - that may be tested using :meth:`ButtonDown` ).
:rtype: `bool`
.. method:: IsPageScroll(self)
Returns ``True`` if the system has been setup to do page scrolling with the mouse wheel instead of line scrolling.
:rtype: `bool`
.. method:: Leaving(self)
Returns ``True`` if the mouse was leaving the window.
:rtype: `bool`
.. seealso:: :meth:`Entering` .
.. method:: LeftDClick(self)
Returns ``True`` if the event was a left double click.
:rtype: `bool`
.. method:: LeftDown(self)
Returns ``True`` if the left mouse button changed to down.
:rtype: `bool`
.. method:: LeftUp(self)
Returns ``True`` if the left mouse button changed to up.
:rtype: `bool`
.. method:: MetaDown(self)
Returns ``True`` if the Meta key was down at the time of the event.
:rtype: `bool`
.. method:: MiddleDClick(self)
Returns ``True`` if the event was a middle double click.
:rtype: `bool`
.. method:: MiddleDown(self)
Returns ``True`` if the middle mouse button changed to down.
:rtype: `bool`
.. method:: MiddleUp(self)
Returns ``True`` if the middle mouse button changed to up.
:rtype: `bool`
.. method:: Moving(self)
Returns ``True`` if this was a motion event and no mouse buttons were pressed.
If any mouse button is held pressed, then this method returns ``False`` and :meth:`Dragging` returns ``True``.
:rtype: `bool`
.. method:: RightDClick(self)
Returns ``True`` if the event was a right double click.
:rtype: `bool`
.. method:: RightDown(self)
Returns ``True`` if the right mouse button changed to down.
:rtype: `bool`
.. method:: RightUp(self)
Returns ``True`` if the right mouse button changed to up.
:rtype: `bool`
.. attribute:: LinesPerAction
See :meth:`~wx.MouseEvent.GetLinesPerAction`
.. attribute:: LogicalPosition
See :meth:`~wx.MouseEvent.GetLogicalPosition`
.. attribute:: WheelDelta
See :meth:`~wx.MouseEvent.GetWheelDelta`
.. attribute:: WheelRotation
See :meth:`~wx.MouseEvent.GetWheelRotation`
|