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

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