1 '''
2 Defines an L{AEEvent} indicating that the focus has changed.
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.AEConstants import LAYER_FOCUS
24
26 '''
27 Event that fires when the focused accessible changes.
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 gained: Type of focus change: True if gained, False if lost
35 @type gained: boolean
36 '''
37 Base.registerEventType('FocusChange', True)
38
39 - def __init__(self, por, gained, **kwargs):
40 '''
41 Stores the L{AEPor} for the focused object and the type of focus event.
42
43 @param por: Point-of-regard from the accessible that just got focus
44 @type por: L{AEPor}
45 @param gained: Was focused gained or lost?
46 @type gained: boolean
47 '''
48 Base.AEEvent.__init__(self, **kwargs)
49 self.por = por
50 self.gained = gained
51
53 '''
54 Returns a human readable representation of this event including its name,
55 its L{AEPor}, and its type.
56
57 @return: Information about this event
58 @rtype: string
59 '''
60 name = Base.AEEvent.__str__(self)
61 if self.gained:
62 action = 'gained'
63 else:
64 action = 'lost'
65 return '%s:\n\tPOR: %s\n\taction: %s' % (name, self.por, action)
66
68 '''
69 Returns the L{AEPor} for this focus event. Used by L{AETier} to maintain a
70 focus L{AEPor}.
71
72 @return: Point-of-regard for this focus event
73 @rtype: L{AEPor}
74 '''
75 return self.por
76
78 '''
79 Fetches data out of this L{FocusChange} for use by a
80 L{AEScript.EventScript.onFocusChange}.
81
82 @return: Dictionary of parameters to be passed to a
83 L{AEScript.EventScript.onFocusChange} as follows:
84 - por: The L{AEPor} of the accessible in which the focus change occured
85 - type: Whether focus was gained (True) or lost (False)
86 @rtype: dictionary
87 '''
88 return {'por' : self.getPOR(), 'gained' : self.gained}
89
103