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
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)
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
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
92
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
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