Package library :: Package pyjamas :: Package ui :: Module RichTextAreaImpl
[hide private]
[frames] | no frames]

Source Code for Module library.pyjamas.ui.RichTextAreaImpl

 1  """ 
 2  * Copyright 2007 Google Inc. 
 3  # Copyright (C) 2009 Luke Kenneth Casson Leighton <lkcl@lkcl.net> 
 4  * 
 5  * Licensed under the Apache License, Version 2.0 (the "License"); you may not 
 6  * use this file except in compliance with the License. You may obtain a copy of 
 7  * the License at 
 8  * 
 9  * http:#www.apache.org/licenses/LICENSE-2.0 
10  * 
11  * Unless required by applicable law or agreed to in writing, software 
12  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 
13  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 
14  * License for the specific language governing permissions and limitations under 
15  * the License. 
16  """ 
17   
18   
19  from pyjamas import DOM 
20   
21  from pyjamas.ui import Event 
22  from pyjamas.ui import Focus 
23   
24  """* 
25  * Base class for RichText platform implementations. The default version 
26  * simply creates a text area with no rich text support. 
27  * 
28  * This is not currently used by any user-agent, but will provide a 
29  * &lt;textarea&gt; fallback in the event a future browser fails to implement 
30  * rich text editing. 
31  """ 
32 -class RichTextAreaImpl:
33
34 - def __init__(self):
35 self.elem = self.createElement()
36 37
38 - def getElement(self):
39 return self.elem
40 41
42 - def getHTML(self):
43 return DOM.getElementProperty(self.elem, "value")
44 45
46 - def getText(self):
47 return DOM.getElementProperty(self.elem, "value")
48 49
50 - def initElement(self):
52 53
54 - def isBasicEditingSupported(self):
55 return False
56 57
59 return False
60 61
62 - def setHTML(self, html):
63 DOM.setElementProperty(self.elem, "value", html)
64 65
66 - def setText(self, text):
67 DOM.setElementProperty(self.elem, "value", text)
68 69
70 - def uninitElement(self):
71 pass
72 73
74 - def setFocus(self, focused):
75 if (focused): 76 Focus.focus(self.getElement()) 77 else: 78 Focus.blur(self.getElement())
79
80 - def createElement(self):
81 return DOM.createTextArea()
82 83
84 - def hookEvents(self):
85 print self, "hook events" 86 DOM.sinkEvents(self.elem, Event.MOUSEEVENTS | Event.KEYEVENTS | 87 Event.ONCHANGE | Event.ONCLICK | Event.FOCUSEVENTS)
88 89
90 - def onElementInitialized(self):
91 print "onElementInitialized" 92 self.hookEvents()
93
94 - def setCssStyling(self):
95 pass
96