Yes the contextmenu in kitchensink works. the others example dont actually
seem to have contextmenus.
Let me rephrase my question a bit as it seems like you thought i said
pyjamas was broken, but all i meant to say is "how do i..."
in this example below, how can i make the browsers default rightclick menu
(with its standard copy/paste etc) to appear when right clicking on the
textarea which is inside the simplepanel?
class Test(SimplePanel, MouseHandler):
def __init__(self, name, binParent):
SimplePanel.__init__(self)
MouseHandler.__init__(self)
self.setContextMenu(self)
ta = TestArea()
self.add(ta)
self.setWidth("200px")
self.setHeight("200px")
def onContextMenu(self, sender):
#Window.alert("fart!")
event = DOM.eventGetCurrentEvent()
subMenu = MenuBar(True)
subMenu.addItem("Hello", True, MenuCmd(self, "hello"))
x = DOM.eventGetClientX(event) + 2
y = DOM.eventGetClientY(event) + 2
popup = ContextMenuPopupPanel(subMenu)
popup.showAt(0, 0)
popup.setPopupPosition(x,y)
def hello(self):
Window.alert("hello!")
class TestArea(TextArea):
def __init__(self, node):
TextArea.__init__(self)
self.node = node
self.setWidth("100px")
self.setHeight("100px")
Thanks
Gustaf
On Sun, Jan 15, 2012 at 5:29 AM, lkcl luke <[email protected]> wrote:
> On Sun, Jan 15, 2012 at 4:00 AM, Gustaf Nilsson <[email protected]>
> wrote:
> > hola
> >
> > i have a widget with a contextmenu. inside it is a textarea. problem is
> that
> > if i rightclick on the textarea (to use the browsers spell checking for
> > example) then the context menu pops up instead! how can i prevent this?
> > I tried to give the textarea something like:
> >
> > def onContextMenu(self, sender):
> > event = DOM.eventGetCurrentEvent()
> > DOM.eventStopPropagation(event)
> >
> > but it doesnt work. in fact it doesnt even get called even though i
> > have self.setContextMenu(self) in the textareas __init__()
>
> you need to indicate that you wish the application to respond to that
> event type: it's not automatic, because otherwise it would waste CPU
> power calling functions that do.... nothing.
>
> soo.... hmmm... just looking at gwt/ui/Widget.py - you called
> Widget.setContextMenu... hmmm, then i have no idea.
>
> lkcl@teenymac:~/pyjamas/examples$ grep -il contextmen */*.py
> kitchensink/Menus.py
> maparea/MapAreaDemo.py
> minesweeper/minesweeper.py
> raphael/events.py
>
> so - please double-check that the kitchensink Menus example works (and
> minesweeper, and maparea).
>
> l.
--
■ ■ ■ ■ ■ ■ ■ ■ ■ ■