Re: TreeItem child widgets do not have onAttach called
On Aug 11, 12:34 am, Jim Douglas wrote: > Have you considered using this version of TreeItem, which takes a > Widget? > > http://google-web-toolkit.googlecode.com/svn/javadoc/2.3/com/google/g...) > http://google-web-toolkit.googlecode.com/svn/javadoc/2.3/com/google/g...) okay. right. i didn't notice the 2nd link was to TreeItem.setWidget (groups.google.com hid the text *sigh*). that calls tree.adopt. i just went through the code, down to Tree.java. Tree.adopt calls setWidget (the base version). setWidget then calls onAttach. soo... actually... yeah, that might do the trick. it's... klunky (as in, it's non-standard behaviour) and thus is going to catch users out. i.e. if you _don't_ call that setWidget function, you're stuffed. let me investigate further ok? l. -- You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to google-web-toolkit@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
Re: TreeItem child widgets do not have onAttach called
On Aug 11, 12:34 am, Jim Douglas wrote: > Have you considered using this version of TreeItem, which takes a > Widget? > > http://google-web-toolkit.googlecode.com/svn/javadoc/2.3/com/google/g...)http://google-web-toolkit.googlecode.com/svn/javadoc/2.3/com/google/g...) that's the exact [equivalent] class being used, and it's the exact same class [equivalent] that we've made a 6-line patch to, in order to fix the bug that has been found [in the exact corresponding equivalent pyjamas codebase, pyjamas/library/gwt/ui/TreeItem.py]. > The TreeItem isn't itself a Widget, but it can contain a Widget, and > that contained Widget (think of it as a tree item renderer) can manage > its own events. that's the point, jim: it *doesn't* manage its own events, because onAttach is never called on the widgets that are added to the TreeItem. thus, anything that's added to TreeItem is completely isolated, as far as events are concerned. no onClick, no onDoubleClick, no onMouseMove, no onMouseUp - nothing. i apologise - i realise that it's quite difficult to appreciate that the pyjamas codebase is the same - functionally - as GWT, to the point where it's possible to refer developers to the GWT online documentation rather than have to write our own. it's virtually identical to that of GWT, so much so that we can actually use language translator tools (automatic and semi-automatic) to port GWT java to pyjamas python. but, yes, you've correctly identified the gwt UI class that will have the exact same bug that was discovered by a pyjamas user. and, therefore, _because_ the code is effectively identical, there is the exact same bug in GWT. what the user did was to take the code for onAttach and onDetach in pyjamas/library/gwt/ui/Panel.py and cut/paste it into TreeItem.py. thus, correspondingly, to fix this bug in GWT, you (GWT developers) need to take the exact same code that is in the gwt/ui/Panel.java "onAttach" and "onDetach" functions, cut/paste it into gwt/ui/ TreeItem.java and the bug is fixed. @begin namespace GWT's client/ui widgets on all widgets below but first, you need to realise that there _is_ a bug :) for that, you'll need to look at the example test-case provided by the pyjamas user, and port it to GWT. it's actually very simple: add a CheckBox to a TreeItem; add the TreeItem to a Tree; add the Tree to a RootPanel. add a click handler to the CheckBox, which prints "hello world" or something. @end namespace click on the checkbox. you'll find that absolutely *nothing* happens. that's the bug. does that make sense? l. -- You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to google-web-toolkit@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
Re: TreeItem child widgets do not have onAttach called
Have you considered using this version of TreeItem, which takes a Widget? http://google-web-toolkit.googlecode.com/svn/javadoc/2.3/com/google/gwt/user/client/ui/TreeItem.html#TreeItem(com.google.gwt.user.client.ui.Widget) http://google-web-toolkit.googlecode.com/svn/javadoc/2.3/com/google/gwt/user/client/ui/TreeItem.html#setWidget(com.google.gwt.user.client.ui.Widget) The TreeItem isn't itself a Widget, but it can contain a Widget, and that contained Widget (think of it as a tree item renderer) can manage its own events. On Aug 10, 4:25 pm, lkcl wrote: > On Aug 4, 5:36 pm, Jim Douglas wrote: > > > The basic issue here is that TreeItems aren't Widgets, so (by design) > > they don't handle their own events. > > yeeesss... but that doesn't mean that child widgets of TreeItems > should be completely terminated from any possibility of having *their* > events handled, does it. > > > You'll want to review Tree to > > decide how best to manage your events. > > no, we won't [want to review Tree to decide how to best manage > events]. > > allow me to illustrate. > > what you're saying is that, instead of adding about 6 lines of code > (an implementation of onAttach and onDetach which does exactly what > Panel does - calls the onAttach and onDetach of all child widgets, so > that they get joined into the event handling infrastructure), you're > expecting developers to do this: > > * sub-class Tree and/or hook into Event Preview or onBrowserEvent > > * receive *all* events in Tree not just one or two, because you > cannot predict what events the child widgets will want. or, you have > to add duplicated infrastructure to receive and manage events that > somehow magically notify the containing Tree that actually, guys, you > wanted the event callback to be here but really it's gonna be down > here in this random Tree object which you should really have f***-all > knowledge of, it's miles down the hierarchy > > * do a massive recursive node-walk of all TreeItem no wait all > TreeItem _child_ objects, including *recursively* walking the child > objects of the TreeItem child objects in order to identify the GWT (or > in this case pyjamas) object that is associated with the DOM element > that received the event > > * add in infrastructure which duplicates existing code which is part > of the tried-and-tested GWT (or in this case pyjamas) codebase, > hooking *back* into the standard event handling system further up into > the child hierarchy. > > * using that duplicated code, as the correct object has been > identified (through the highly computationally expensive step 3 > above), call the relevant event callback. > > now, when it's put like that - which is what you're asking developers > to do - it does sound a bit like you're completely off your head, > please excuse me for pointing that out. > > 6 lines of code vs 400+ lines of code and a massive runtime > performance hit, duplicating functions that are built-in to web > browsers anyway _and_ duplicating functionality which already exists > in GWT (and pyjamas), there's no real comparison, is there? > > so - i invite you to look at this again, *without* the "static > mindset" of "TreeItems aren't Widgets" [implication being, there's no > way that the code can be either changed or fixed, and no improvements > will ever be made to it]. > > regarding "it's by design" - designs should only remain static if they > actually serve the purpose for which they were designed. in this > case, we have an actual real-world use case which demonstrates that > the design is, 'scuse me for saying it, shit. > > or, perhaps, i invite you to consider describing what possible > implications there could be to TreeItem having an onAttach and > onDetach. you'll find that even UIObject has onAttach and onDetach > (as stubs), so it's not like it's not possible to do this. > > the real question is: does adding onAttach or onDetach have any > unintended consequences / side-effects that need a workaround? for > example, what happens to up-down-left-right-enter key navigation, is > that affected? > > l. -- You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to google-web-toolkit@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
Re: TreeItem child widgets do not have onAttach called
On Aug 4, 5:36 pm, Jim Douglas wrote: > The basic issue here is that TreeItems aren't Widgets, so (by design) > they don't handle their own events. yeeesss... but that doesn't mean that child widgets of TreeItems should be completely terminated from any possibility of having *their* events handled, does it. > You'll want to review Tree to > decide how best to manage your events. no, we won't [want to review Tree to decide how to best manage events]. allow me to illustrate. what you're saying is that, instead of adding about 6 lines of code (an implementation of onAttach and onDetach which does exactly what Panel does - calls the onAttach and onDetach of all child widgets, so that they get joined into the event handling infrastructure), you're expecting developers to do this: * sub-class Tree and/or hook into Event Preview or onBrowserEvent * receive *all* events in Tree not just one or two, because you cannot predict what events the child widgets will want. or, you have to add duplicated infrastructure to receive and manage events that somehow magically notify the containing Tree that actually, guys, you wanted the event callback to be here but really it's gonna be down here in this random Tree object which you should really have f***-all knowledge of, it's miles down the hierarchy * do a massive recursive node-walk of all TreeItem no wait all TreeItem _child_ objects, including *recursively* walking the child objects of the TreeItem child objects in order to identify the GWT (or in this case pyjamas) object that is associated with the DOM element that received the event * add in infrastructure which duplicates existing code which is part of the tried-and-tested GWT (or in this case pyjamas) codebase, hooking *back* into the standard event handling system further up into the child hierarchy. * using that duplicated code, as the correct object has been identified (through the highly computationally expensive step 3 above), call the relevant event callback. now, when it's put like that - which is what you're asking developers to do - it does sound a bit like you're completely off your head, please excuse me for pointing that out. 6 lines of code vs 400+ lines of code and a massive runtime performance hit, duplicating functions that are built-in to web browsers anyway _and_ duplicating functionality which already exists in GWT (and pyjamas), there's no real comparison, is there? so - i invite you to look at this again, *without* the "static mindset" of "TreeItems aren't Widgets" [implication being, there's no way that the code can be either changed or fixed, and no improvements will ever be made to it]. regarding "it's by design" - designs should only remain static if they actually serve the purpose for which they were designed. in this case, we have an actual real-world use case which demonstrates that the design is, 'scuse me for saying it, shit. or, perhaps, i invite you to consider describing what possible implications there could be to TreeItem having an onAttach and onDetach. you'll find that even UIObject has onAttach and onDetach (as stubs), so it's not like it's not possible to do this. the real question is: does adding onAttach or onDetach have any unintended consequences / side-effects that need a workaround? for example, what happens to up-down-left-right-enter key navigation, is that affected? l. -- You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to google-web-toolkit@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
Re: TreeItem child widgets do not have onAttach called
The basic issue here is that TreeItems aren't Widgets, so (by design) they don't handle their own events. You'll want to review Tree to decide how best to manage your events. http://google-web-toolkit.googlecode.com/svn/javadoc/2.3/com/google/gwt/user/client/ui/Tree.html http://google-web-toolkit.googlecode.com/svn/javadoc/2.3/com/google/gwt/user/client/ui/TreeItem.html http://www.google.com/codesearch#A1edwVHBClQ/user/src/com/google/gwt/user/client/ui/Tree.java http://www.google.com/codesearch#A1edwVHBClQ/user/src/com/google/gwt/user/client/ui/TreeItem.java On Aug 4, 6:08 am, lkcl wrote: > folks hi, > > this is luke, the lead developer of the python port of GWT. we > regularly track the GWT source code, to the point of having 3 > different semi-automated java-to-python converters of varying levels > of sophistication, and the reason for doing that is to save vast > amounts of time and resources, because the GWT source code is much > more tested. > > _very_ occasionally we find a bug in GWT which has been transferred - > verbatim - from the direct translation to python. it would be very > good, therefore, to have peoples' input on this issue, and to have a > discussion of this bug which could affect users of both GWT and > pyjamas. > > the issue is this: a user has created a Tree and has placed TreeItems > in it, and then attached a CheckBox onto the TreeItem. the problem is > that in these CheckBoxes, no onClicks or any other kind of event > handling occur, period. > > now, i'm dead impressed that this new pyjamas developer then went and > delved into the pyjs ui source code and found the problem _and_ > created a fix:http://code.google.com/p/pyjamas/issues/?id=638 > > diff --git a/library/gwt/ui/TreeItem.py b/library/gwt/ui/TreeItem.py > index f5c0489..d5a413f 100644 > --- a/library/gwt/ui/TreeItem.py > +++ b/library/gwt/ui/TreeItem.py > @@ -127,10 +127,18 @@ class TreeItem(UIObject): > return item > > def onAttach(self): > - pass > + for item in self.children: > + item.onAttach() > + w = self.getWidget() > + if w: > + w.onAttach() > > def onDetach(self): > - pass > + for item in self.children: > + item.onDetach() > + w = self.getWidget() > + if w: > + w.onDetach() > > def getChild(self, index): > if (index < 0) or (index >= len(self.children)): > > so, the question that i have is very simple: is this the right thing > to do? remember that, as we didn't design the GWT UI widget > infrastructure (merely "port" it pretty much verbatim to python), > analysing the implications of issues such as this is somewhat outside > of our... scope / resources / time / "community abilities" shall we > say. > > plus, i believe it's important to raise this with the GWT community > not least because someone else in the GWT community may wish to do > exactly the same thing: have TreeItems where the widgets within them > bloody well work! :) > > i'd be interested to hear the thoughts of the GWT community on this > issue. fyi read-only archive of pyjamas-dev exact same topic is > here:http://groups.google.com/group/pyjamas-dev/browse_thread/thread/b69ad... > > l. -- You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to google-web-toolkit@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
Re: TreeItem child widgets do not have onAttach called
okaay... rright: the message took its sweet time to appear here in the forum, and so i couldn't cross-reference the forum with the bugreport until that had happened, duh, so now that's happened, here's the reference: http://code.google.com/p/google-web-toolkit/issues/detail?id=6656 -- You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to google-web-toolkit@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
TreeItem child widgets do not have onAttach called
folks hi, this is luke, the lead developer of the python port of GWT. we regularly track the GWT source code, to the point of having 3 different semi-automated java-to-python converters of varying levels of sophistication, and the reason for doing that is to save vast amounts of time and resources, because the GWT source code is much more tested. _very_ occasionally we find a bug in GWT which has been transferred - verbatim - from the direct translation to python. it would be very good, therefore, to have peoples' input on this issue, and to have a discussion of this bug which could affect users of both GWT and pyjamas. the issue is this: a user has created a Tree and has placed TreeItems in it, and then attached a CheckBox onto the TreeItem. the problem is that in these CheckBoxes, no onClicks or any other kind of event handling occur, period. now, i'm dead impressed that this new pyjamas developer then went and delved into the pyjs ui source code and found the problem _and_ created a fix: http://code.google.com/p/pyjamas/issues/?id=638 diff --git a/library/gwt/ui/TreeItem.py b/library/gwt/ui/TreeItem.py index f5c0489..d5a413f 100644 --- a/library/gwt/ui/TreeItem.py +++ b/library/gwt/ui/TreeItem.py @@ -127,10 +127,18 @@ class TreeItem(UIObject): return item def onAttach(self): -pass +for item in self.children: +item.onAttach() +w = self.getWidget() +if w: + w.onAttach() def onDetach(self): -pass +for item in self.children: +item.onDetach() +w = self.getWidget() +if w: + w.onDetach() def getChild(self, index): if (index < 0) or (index >= len(self.children)): so, the question that i have is very simple: is this the right thing to do? remember that, as we didn't design the GWT UI widget infrastructure (merely "port" it pretty much verbatim to python), analysing the implications of issues such as this is somewhat outside of our... scope / resources / time / "community abilities" shall we say. plus, i believe it's important to raise this with the GWT community not least because someone else in the GWT community may wish to do exactly the same thing: have TreeItems where the widgets within them bloody well work! :) i'd be interested to hear the thoughts of the GWT community on this issue. fyi read-only archive of pyjamas-dev exact same topic is here: http://groups.google.com/group/pyjamas-dev/browse_thread/thread/b69ad20a6af2085e l. -- You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to google-web-toolkit@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.