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 pyjamas.ui.UIObject import UIObject
19 from pyjamas.ui import Event
20 from pyjamas.ui.InnerHTML import InnerHTML
21 from pyjamas.ui.InnerText import InnerText
22
24
25
26
27
28
30 cmd = None
31 if subMenu is None:
32 if hasattr(asHTML, "execute"):
33 cmd = asHTML
34 asHTML = False
35 elif hasattr(asHTML, "onShow"):
36 subMenu = asHTML
37 asHTML = False
38
39 elif hasattr(subMenu, "execute"):
40 cmd = subMenu
41 subMenu = None
42
43
44 self.command = None
45 self.parentMenu = None
46 self.subMenu = None
47
48 if kwargs.has_key('Element'):
49 element = kwargs.pop('Element')
50 else:
51 element = DOM.createTD()
52 self.setElement(element)
53
54 kwargs['SelectionStyle'] = False
55 if asHTML:
56 kwargs['HTML'] = text
57 else:
58 kwargs['Text'] = text
59
60 if cmd:
61 kwargs['Command'] = cmd
62 if subMenu:
63 kwargs['SubMenu'] = subMenu
64
65 if not kwargs.has_key('StyleName'): kwargs['StyleName']="gwt-MenuItem"
66
67 UIObject.__init__(self, **kwargs)
68 self.sinkEvents(Event.ONCLICK | Event.ONMOUSEOVER | Event.ONMOUSEOUT)
69
70
71
72
73
74
75
76
77
78
79
80
81
82
85
87 return self.parentMenu
88
91
94
96 self.subMenu = subMenu
97
99 self.parentMenu = parentMenu
100
106
107 Factory.registerClass('pyjamas.ui.MenuItem', 'MenuItem', MenuItem)
108