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

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