The Events3D Module¶
Project Name: MakeHuman
Product Home Page: http://www.makehuman.org/
Code Home Page: https://bitbucket.org/MakeHuman/makehuman/
Authors: Marc Flerackers
Copyright(c): MakeHuman Team 2001-2017
Licensing: AGPL3
This file is part of MakeHuman (www.makehuman.org).
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
Abstract¶
This module contains classes to allow an object to handle events.
-
class
events3d.
EventHandler
[source]¶ Base event handler class. Derive from this class if an object needs to be able to have events attached to it. Currently only one event per event name can be attached. This is because we either allow a class method or a custom method to be attached as event handling method. Since the custom method replaces the class method, it is needed in some case to call the base class’s method from the event handling method.
There are 2 ways to attach handlers:
- Override the method. This is the most appropriate way when you want to add distinctive behaviour to many EventHandlers.
class Widget(View): def onMouseDown(self, event): #Handle event
- Use the event decorator. This is the most appropriate way when you want to attach distinctive behaviour to one EventHandler.
widget = Widget() @widget.mhEvent: def onMouseDown(event): #Handle event
Note that self is not passed to the handler in this case, which should not be a problem as you can just use the variable since you are creating a closure.
-
class
events3d.
FocusEvent
(blurred, focused)[source]¶ Contains information about a view focus/blur event
Parameters: - blurred (guid3d.View) – the view that lost the focus.
- focused (guid3d.View) – the view that gained the focus.
-
class
events3d.
KeyEvent
(key, character, modifiers)[source]¶ Contains information about a keyboard event.
Parameters: - key (int) – the key code of the key that was pressed or released.
- character (unicode) – the unicode character if the key represents a character.
- modifiers (int) – the modifier keys that were down at the time of pressing the key.
-
class
events3d.
MouseEvent
(button, x, y, dx=0, dy=0)[source]¶ Contains information about a mouse event.
Parameters: - button (int) – the button that is pressed in case of a mousedown or mouseup event, or button flags in case of a mousemove event.
- x (int) – the x position of the mouse in window coordinates.
- y (int) – the y position of the mouse in window coordinates.
- dx (int) – the difference in x position in case of a mousemove event.
- dy (int) – the difference in y position in case of a mousemove event.
-
class
events3d.
MouseWheelEvent
(wheelDelta, x, y)[source]¶ Contains information about a mouse wheel event.
Parameters: wheelDelta (int) – the amount and direction that the wheel was scrolled.
-
class
events3d.
ResizeEvent
(width, height, fullscreen)[source]¶ Contains information about a resize event
Parameters: - width (int) – the new width of the window in pixels.
- height (int) – the new height of the window in pixels.
- fullscreen (Boolean) – the new fullscreen state of the window.
- dx (int) – the change in width of the window in pixels.
- dy (int) – the change in height of the window in pixels.