1 #Copyright (C) 2008 Codethink Ltd
3 #This library is free software; you can redistribute it and/or
4 #modify it under the terms of the GNU Lesser General Public
5 #License version 2 as published by the Free Software Foundation.
7 #This program is distributed in the hope that it will be useful,
8 #but WITHOUT ANY WARRANTY; without even the implied warranty of
9 #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 #GNU General Public License for more details.
11 #You should have received a copy of the GNU Lesser General Public License
12 #along with this program; if not, write to the Free Software
13 #Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
15 from interfaces import *
16 from factory import accessible_factory
23 #------------------------------------------------------------------------------
25 class EditableText(Text):
27 Derived from interface Text, EditableText provides methods for
28 modifying textual content of components which support editing.
29 EditableText also interacts with the system clipboard via copyText,
30 cutText, and pasteText.
33 def copyText(self, start, end):
35 Copy a range of text into the system clipboard.
37 the character offset of the first character in the range of text
40 the offset of the first character past the end of the range of
43 func = self.get_dbus_method("copyText", dbus_interface=ATSPI_EDITABLE_TEXT)
44 return func(start, end)
46 def cutText(self, start, end):
48 Excise a range of text from a Text object, copying it into the
51 the character offset of the first character in the range of text
54 the offset of the first character past the end of the range of
56 @return True if the text was successfully cut, False otherwise.
58 func = self.get_dbus_method("cutText", dbus_interface=ATSPI_EDITABLE_TEXT)
59 return func(start, end)
61 def deleteText(self, start, end):
63 Excise a range of text from a Text object without copying it
64 into the system clipboard.
66 the character offset of the first character in the range of text
69 the offset of the first character past the end of the range of
71 @return True if the text was successfully deleted, False otherwise.
73 func = self.get_dbus_method("deleteText", dbus_interface=ATSPI_EDITABLE_TEXT)
74 return func(start, end)
76 def insertText(self, position, text, length):
78 Insert new text contents into an existing text object at a given
79 location, while retaining the old contents.
81 the character offset into the Text implementor's content at which
82 the new content will be inserted.
84 a UTF-8 string of which length characters will be inserted into
85 the text object's text buffer.
87 the number of characters of text to insert. If the character
88 count of text is less than or equal to length, the entire contents
89 of text will be inserted.
90 @return True if the text content was successfully inserted, False
93 func = self.get_dbus_method("insertText", dbus_interface=ATSPI_EDITABLE_TEXT)
94 return func(position, text, length)
96 def pasteText(self, position):
98 Copy the text contents of the system clipboard, if any, into
99 a Text object, inserting it at a particular character offset.
101 the character offset before which the text will be inserted.
102 @return True if the text was successfully pasted into the Text
103 object, False otherwise.
105 func = self.get_dbus_method("pasteText", dbus_interface=ATSPI_EDITABLE_TEXT)
106 return func(position)
108 def setTextContents(self, contents):
110 Replace the text contents with a new string, discarding the old
113 a UTF-8 string with which the text object's contents will be
115 @return True if the text content was successfully changed, False
118 func = self.get_dbus_method("setTextContents", dbus_interface=ATSPI_EDITABLE_TEXT)
119 return func(contents)
121 # Register the accessible class with the factory.
122 accessible_factory.register_accessible_class(ATSPI_EDITABLE_TEXT, EditableText)
124 #END----------------------------------------------------------------------------