Package Task :: Module FocusTask
[hide private]
[frames] | no frames]

Source Code for Module Task.FocusTask

 1  ''' 
 2  Defines a Task to execute when the focus changes. 
 3   
 4  @author: Peter Parente 
 5  @author: Pete Brunet 
 6  @organization: IBM Corporation 
 7  @copyright: Copyright (c) 2005, 2007 IBM Corporation 
 8  @license: The BSD License 
 9   
10  All rights reserved. This program and the accompanying materials are made  
11  available under the terms of the BSD license which accompanies 
12  this distribution, and is available at 
13  U{http://www.opensource.org/licenses/bsd-license.php} 
14  ''' 
15   
16  import Base, EventTask 
17  import AEEvent 
18   
19 -class FocusTask(EventTask.EventTask):
20 ''' 21 Executed when a focus change occurs. 22 23 This class registers its name and whether it should be monitored by default 24 in an L{AEMonitor} using the L{Base.registerTaskType} function when this 25 module is first imported. The L{AEMonitor} can use this information to build 26 its menus. 27 ''' 28 Base.registerTaskType('FocusTask', True) 29
30 - def getEventType(self):
31 ''' 32 @return: Type of L{AEEvent} this L{Task} wants to handle 33 @rtype: class 34 ''' 35 return AEEvent.FocusChange
36
37 - def update(self, por, gained, layer, **kwargs):
38 ''' 39 Updates this L{Task} in response to a consumed focus change event. Called 40 by L{Tier.Tier._executeTask}. 41 42 @param por: Point of regard related at which the event occurred 43 @type por: L{POR} 44 @param gained: Was focus gained (True) or lost (False) 45 @type gained: boolean 46 @param layer: Layer on which the event occurred 47 @type layer: integer 48 ''' 49 pass
50
51 - def execute(self, por, gained, layer, **kwargs):
52 ''' 53 Executes this L{Task} in response to a focus change event. Called by 54 L{Tier.Tier._executeTask}. 55 56 @param por: Point of regard related at which the event occurred 57 @type por: L{POR} 58 @param gained: Was focus gained (True) or lost (False) 59 @type gained: boolean 60 @param layer: Layer on which the event occurred 61 @type layer: integer 62 @return: True to allow other L{Task}s to process this event 63 @rtype: boolean 64 ''' 65 if gained: 66 return self.executeGained(por=por, layer=layer, **kwargs) 67 else: 68 return self.executeLost(por=por, layer=layer, **kwargs)
69
70 - def executeGained(self, por, layer, **kwargs):
71 ''' 72 Executes this L{Task} in response to a focus gained event. Called by 73 L{execute}. 74 75 @param por: Focused point of regard 76 @type por: L{POR} 77 @param layer: Layer on which the event occurred 78 @type layer: integer 79 @return: True to allow other L{Task}s to process this event 80 @rtype: boolean 81 ''' 82 return True
83
84 - def executeLost(self, por, layer, **kwargs):
85 ''' 86 Executes this L{Task} in response to a focus lost event. Called by 87 L{execute}. 88 89 @param por: Unfocused point of regard 90 @type por: L{POR} 91 @param layer: Layer on which the event occurred 92 @type layer: integer 93 @return: True to allow other L{Task}s to process this event 94 @rtype: boolean 95 ''' 96 return True
97