1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 from pyjamas import DOM
16 from pyjamas import Factory
17
18 from UIObject import UIObject
19 from pyjamas.ui import Event
20 from pyjamas.ui import InnerHTML, InnerText
21
23
24
25
26
27
29 cmd = None
30 if subMenu is None:
31 if hasattr(asHTML, "execute"):
32 cmd = asHTML
33 asHTML = False
34 elif hasattr(asHTML, "onShow"):
35 subMenu = asHTML
36 asHTML = False
37
38 elif hasattr(subMenu, "execute"):
39 cmd = subMenu
40 subMenu = None
41
42
43 self.command = None
44 self.parentMenu = None
45 self.subMenu = None
46
47 if kwargs.has_key('Element'):
48 element = kwargs.pop('Element')
49 else:
50 element = DOM.createTD()
51 self.setElement(element)
52
53 kwargs['SelectionStyle'] = False
54 if asHTML:
55 kwargs['HTML'] = text
56 else:
57 kwargs['Text'] = text
58
59 if cmd:
60 kwargs['Command'] = cmd
61 if subMenu:
62 kwargs['SubMenu'] = subMenu
63
64 if not kwargs.has_key('StyleName'): kwargs['StyleName']="gwt-MenuItem"
65
66 UIObject.__init__(self, **kwargs)
67 self.sinkEvents(Event.ONCLICK | Event.ONMOUSEOVER | Event.ONMOUSEOUT)
68
71
73 return self.parentMenu
74
77
80
82 self.subMenu = subMenu
83
85 self.parentMenu = parentMenu
86
92
93 Factory.registerClass('pyjamas.ui.MenuItem', MenuItem)
94