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

Source Code for Module AccessEngine.AEEvent.SelectorChange

  1  ''' 
  2  Defines an L{AEEvent} indicating that the selector has moved. 
  3   
  4  @author: Pete Brunet 
  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  from AccessEngine.AEConstants import LAYER_FOCUS 
 25   
26 -class SelectorChange(Base.AEEvent):
27 ''' 28 Event that fires when the selector moves. 29 30 This class registers its name and whether it should be monitored by default in 31 an L{AEMonitor} using the L{Base.registerEventType} function 32 when this module is first imported. The L{AEMonitor} can use this 33 information to build its menus. 34 35 @ivar text: Accessible text associated with the event, typically the item 36 text or the selected text 37 @type text: string 38 ''' 39 Base.registerEventType('SelectorChange', True)
40 - def __init__(self, por, text, kind=AEConstants.EVENT_ACTIVE_ITEM_SELECT, 41 **kwargs):
42 ''' 43 Calls the base class (which set the event priority) and then stores the 44 item to be passed along to the AETier as part of the event. 45 46 @param por: Point-of-regard 47 @type por: L{AEPor <AEPor.AEPor>} 48 @param text: Accessible text associated with the event, typically the 49 item text or the selected text 50 @type text: string 51 @param kind: Kind of selection event 52 @type kind: integer 53 ''' 54 Base.AEEvent.__init__(self, **kwargs) 55 self.text = text 56 self.por = por 57 self.kind = kind
58
59 - def __str__(self):
60 ''' 61 Returns a human readable representation of this event including its name, 62 its L{AEPor <AEPor.AEPor>}, and its item text. 63 64 @return: Information about this event 65 @rtype: string 66 ''' 67 name = Base.AEEvent.__str__(self) 68 if self.kind == AEConstants.EVENT_ACTIVE_ITEM_SELECT: 69 action = 'active' 70 elif self.kind == AEConstants.EVENT_ADD_ITEM_SELECT: 71 action = 'add' 72 elif self.kind == AEConstants.EVENT_REMOVE_ITEM_SELECT: 73 action = 'remove' 74 else: 75 action = 'text' 76 return '%s:\n\tPOR: %s\n\titem text: %s\n\taction: %s' % \ 77 (name, self.por, self.text, action)
78
79 - def execute(self):
80 ''' 81 Contacts the L{AETierManager} so it can manage the selector change event. 82 83 @return: True if there is an active view, False if not to delay execution 84 of this event until there is 85 @rtype: boolean 86 ''' 87 if AccessEngine.AEViewManager.getAEView() is None and self.layer == LAYER_FOCUS: 88 return False 89 else: 90 AccessEngine.AETierManager.manageEvent(self) 91 return True
92
93 - def getFocusPOR(self):
94 ''' 95 Returns the L{AEPor <AEPor.AEPor>} for active item events. Used by L{AETier} 96 to maintain a focus L{AEPor <AEPor.AEPor>}. 97 98 @return: Point-of-regard for this focus event 99 @rtype: L{AEPor <AEPor.AEPor>} 100 @raise AttributeError: When the event does not represent a change in the 101 focus 102 ''' 103 if (self.layer != LAYER_FOCUS or 104 self.kind != AEConstants.EVENT_ACTIVE_ITEM_SELECT): 105 raise AttributeError 106 return self.por
107
108 - def getDataForTask(self):
109 ''' 110 Fetches data out of this L{SelectorChange} for use by a 111 L{AEScript.EventScript.onSelectorChange}-Task. 112 113 @return: Dictionary of parameters to be passed to a 114 L{AEScript.EventScript.onCaretChange}-Task as follows: 115 - por: The L{AEPor <AEPor.AEPor>} pointing at the item at which 116 selection changed or the current caret location for a text 117 selection change 118 - text: The text now selected or unselected 119 - kind: The kind of selection change 120 @rtype: dictionary 121 ''' 122 return {'por':self.getPOR(), 'text':self.text, 'kind':self.kind}
123