Package AEEvent :: Module MouseChange
[hide private]
[frames] | no frames]

Source Code for Module AEEvent.MouseChange

 1  ''' 
 2  Defines an L{AEEvent} indicating that a mouse event occurred. 
 3   
 4  @author: Peter Parente 
 5  @organization: IBM Corporation 
 6  @copyright: Copyright (c) 2005, 2007 IBM Corporation 
 7  @license: The BSD License 
 8   
 9  All rights reserved. This program and the accompanying materials are made  
10  available under the terms of the BSD license which accompanies 
11  this distribution, and is available at 
12  U{http://www.opensource.org/licenses/bsd-license.php} 
13  ''' 
14  import Base 
15  import AEConstants 
16   
17 -class MouseChange(Base.AccessEngineEvent):
18 ''' 19 Event that fires when the mouse cursor moves or a button is pressed. 20 21 This class registers its name and whether it should be monitored by default in 22 an L{AEMonitor} using the L{Base.registerEventType} function 23 when this module is first imported. The L{AEMonitor} can use this 24 information to build its menus. 25 26 @ivar kind: Kind of mouse event 27 @type kind: integer 28 @ivar pos: Absolute position of the mouse pointer 29 @type pos: 2-tuple of integer 30 @ivar button: Number of the button pressed 31 @type button: integer 32 ''' 33 Base.registerEventType('MouseChange', False) 34
35 - def __init__(self, kind, pos=None, button=None, **kwargs):
36 ''' 37 Calls the base class and stores the kind and position or button number. 38 39 @param kind: Kind of mouse event 40 @type kind: integer 41 @param pos: Absolute position of the mouse pointer 42 @type pos: 2-tuple of integer 43 @param button: Number of the button pressed or released 44 @type button: integer 45 ''' 46 Base.AccessEngineEvent.__init__(self, focused=True, **kwargs) 47 self.kind = kind 48 self.pos = pos 49 self.button = button
50
51 - def __str__(self):
52 ''' 53 Returns a human readable representation of this event including its name, 54 its kind, and its absolute position. 55 56 @return: Information about this event 57 @rtype: string 58 ''' 59 name = Base.AccessEngineEvent.__str__(self) 60 if self.kind == AEConstants.MOVE: 61 action = 'move' 62 return '%s:\n\taction: %s\n\tposition: %s' % (name, action, self.pos) 63 else: 64 if self.kind == AEConstants.PRESS: 65 action = 'press' 66 return '%s:\n\taction: %s\n\tbutton: %s' % (name, action, self.button) 67 else: 68 action = 'release' 69 return '%s:\n\taction: %s\n\tbutton: %s' % (name, action, self.button)
70
71 - def execute(self, tier_manager, **kwargs):
72 ''' 73 Contacts the L{TierManager} so it can manage the mouse event. 74 75 @param tier_manager: TierManager that will handle the event 76 @type tier_manager: L{TierManager} 77 @param kwargs: Packed references to other managers not of interest here 78 @type kwargs: dictionary 79 @return: Always True to indicate the event executed properly 80 @rtype: boolean 81 ''' 82 tier_manager.manageEvent(self) 83 return True
84
85 - def getDataForTask(self):
86 ''' 87 Fetches data out of this L{MouseChange} for use by a L{Task.MouseTask}. 88 89 @return: Dictionary of parameters to be passed to a L{Task.MouseTask} as 90 follows: 91 - kind: The kind of mouse event 92 - pos: The new absolute position of the cursor 93 - button: The number of the button pressed or released 94 @rtype: dictionary 95 ''' 96 return {'kind':self.kind, 'pos':self.pos, 'button':self.button}
97