HTMLTable.addTableListener, Button onClick not functioning - all due to PanelBase.__len__ #228

Open
pyjsorg opened this Issue Apr 27, 2012 · 5 comments

Projects

None yet

1 participant

@pyjsorg

HTMLTable.addTableListener no longer seems to work.
This can be simply demonstrated in the GridTest example
by adding the line:

self.g.addTableListener(self)

to GridWidget.init
and defining an onCellClicked function in GridWidget like

def onCellClicked(self,sender,row,col):
print 'Clicked cell ',row, col

This worked in a pyjamas release downloaded 15/08/10 but not in current
release. I can't pin it down more closely as I don't know how to access intermediate releases. The behaviour is the same in pyjd on Windows 7 and pyjs under Firefox 3.6.8, Chrome 6.0.472.55 and IE 8.0.7600.16385.

Incidentally, HTMLTable.clear only removes widgets from the cells but I think it should also clear the cells.
In that case the HTMLTable.clear method should read

def clear(self):
    for row in range(self.getRowCount()):
        for col in range(self.getCellCount(row)):
            child = self.getWidget(row, col)
            if child is not None:
                self.removeWidget(child)
            self.clearCell(row,col)   # added

Original issue: http://code.google.com/p/pyjamas/issues/detail?id=491 (September 09, 2010 16:31:53)

@pyjsorg

From luke.lei...@gmail.com on September 09, 2010 16:36:02:
ah. this is due to get_listener in e.g. DOM.py and then "if listener" which of course tests for len on Panels due to PanelBase and argh it returns False if there are no child items in the Panel. in the case of GridTest, there are only HTML text entries - no actual widgets - so yes, len returns 0.

this is a high-priority item to test absolutely everything.

argh.

@pyjsorg

From jpcharle...@gmail.com on September 16, 2010 17:49:52:
Seems to work OK in pyjs now but not in pyjd on mshtml. I've spent quite a while trying to track down the problem, following your remarks above but haven't managed to pin it down, probably because I still find event handling very confusing.

@pyjsorg

From luke.lei...@gmail.com on September 17, 2010 14:42:06:
it's nothing to do with event handling, it's everything to do with not testing "if {widget} is None" instead there are places where we do "if {widget}".

and given now that PanelBase now has len, "if widget" ends up calling widget.len which can return 0, which equates to False, if there are no children in the widget.

you understand?

thus, even though the test "if widget" is supposed to return True because the widget exists the test fails... merely because the widget is a panel that has no children.

l.

@pyjsorg

From jpcharle...@gmail.com on September 21, 2010 09:07:46:
lkcl,
Re your previous comment, yes, I finally managed to track down where the click events were disappearing and why. I have modified DOMmshtml._dispatchEvent to match the modifications previously made to DOM._dispatchEvent. HTMLTable now has click events again under mshtml.
Diff file is attached.
P.

@pyjsorg

From luke.lei...@gmail.com on September 21, 2010 10:16:19:
goood stuff.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment