am a complete newbie in Pyjamas, and am following the book with great 
interest.

Now, looking at the “writing widgets” part, I have been struggling to get 
things to work. This mostly because the PDF version of the book I had been 
using was somewhat obsolete. Mea culpa...

Then I realised that the methods onClick() and moveSlider() should be 
defined on the VerticalDemoSlider class, and not on the  ControlDemo class, 
as said in the book (there is an erratum  there).

Then the onClick method was called with one argument instead of 2.  The 
‘event’ arg was missing (thank you pyjd for the stack trace...).

Then, looking for ui.py, I found out that the file does not exist, and is a 
directory. I located the onBrowserEvent() method on the ClickListener 
class, in ClickListener.py.  This is another erratum.


This is where I am stuck : If i don’t get the event, I don’t get the y 
position. Is there another way to get it or should the method on 
ClickListener be modified ?

Modifying the method solved the problem, and I got the slider working (at 
least this part).  Now I don’t know if it is correct. Removing the argument 
from the call in ClickListener may have been done for a reason. So the 
question is : Is there a bug in ClickListener.py (event should be passed as 
an argument to onClick() ? or should the book be modified to take this into 
account ?

Here is the code of the method I modified in ClickListener. Modifications 
are in *bold* :


*def onBrowserEvent(self, event):*
*        """Listen to events raised by the browser and call the appropriate
       method of the listener (widget, ..) object.
       """
       type = DOM.eventGetType(event)
       if type == "click":
           if self._clickPreventDefault:
               DOM.eventPreventDefault(event)
           for listener in self._clickListeners:
               if hasattr(listener, "onClick"):
                   listener.onClick(self,event)
               else:
                   listener(self,event)
       elif type == "dblclick":
           if self._clickPreventDefault:
               DOM.eventPreventDefault(event)
           for listener in self._doubleclickListeners:
               if hasattr(listener, "onDoubleClick"):
                   listener.onDoubleClick(self,event)
               else:
                   listener(self,event)*



Best regards,

Éric

-- 



Reply via email to