Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
Where should we report about typo(-s) in docs? — Gideros Forum

Where should we report about typo(-s) in docs?

papirosnikpapirosnik Member
edited April 2016 in Bugs and issues
In particulary, have found one here: http://docs.giderosmobile.com/events.htm#stop
In this example below, MOUSE_DOWN event is dispatched only to F, E, D and C:
Shoould be
... only to F, E, D and B

Comments

  • john26john26 Maintainer
    Hmm, I think the documentation is actually correct. See the diagram on the "input events" tab. The event gets to C and is stopped there. It never reaches B. (C is processed before B, reverse order)
  • john26john26 Maintainer
    edited April 2016
    Well I tried it out to see what actually happens and the result seems to be different from what the documentation says:

    Here's the full code I wrote
    TextBox=Core.class(Sprite)
     
    function TextBox:init(font,str,width,height,border)
     
       local r=Shape.new()
     
       if border then
          r:setLineStyle(2,0x000000)
          r:setFillStyle(Shape.SOLID,0xFFFFFF)
       end
     
       r:beginPath()
       r:moveTo(-width/2,-height/2)
       r:lineTo( width/2,-height/2)
       r:lineTo( width/2, height/2)
       r:lineTo(-width/2, height/2)
       r:closePath()
       r:endPath()
     
       self:addChild(r)
     
       if str then
          local t=TextField.new(font,str)
          local w=t:getWidth()
          local h=t:getHeight()
          t:setPosition(-math.floor(w/2),math.floor(h/2))
     
          self:addChild(t)
       end
     
    --   self:addEventListener(Event.ENTER_FRAME,self.update,self)
       self:addEventListener(Event.MOUSE_DOWN,self.onMouseDown,self)
       self.name=str
    end
     
    function TextBox:update()
       print ("Enter frame=",self.name)
    end
     
    function TextBox:onMouseDown(event)
       print ("Mouse Down=",self.name)
       if self.name=="C" then 
         event:stopPropagation()
       end
    end
     
    -----------------------------------------------
     
    local A = TextBox.new(nil,"A",50,50,true)
    local B = TextBox.new(nil,"B",50,50,true)
    local C = TextBox.new(nil,"C",50,50,true)
    local D = TextBox.new(nil,"D",50,50,true)
    local E = TextBox.new(nil,"E",50,50,true)
    local F = TextBox.new(nil,"F",50,50,true)
     
    A:addChild(B)
    A:addChild(C)
    B:addChild(D)
    B:addChild(E)
    C:addChild(F)
     
    stage:addChild(A)
    A:setPosition( 150,100)
    B:setPosition(-40,40)
    C:setPosition(40,40)
    D:setPosition(-40,40)
    E:setPosition( 40,40)
    F:setPosition( 40,40)
    The result is attached (as in the documentation). We can see the draw order is

    A, B, D, E, C, F

    (as expected for a recursive traversal parents drawn before children)

    The order for touch events is

    F, C, E, D, B, A

    (as expected for recursion with children touched before parents -- and children in reverse order)

    If stop propagation is run after C is processed (as in the code), then the touch event is processed in

    F, C only

    So the documentation is not really correct but it gives the right idea. Perhaps it is somewhat oversimplified. The Gideros programmer doesn't need to know the exact order, typically.
    stopprop.png
    336 x 539 - 32K
  • Yeah, I was indeed wrong...
    but my mistake helped to clarify things )
    Thank for your explanation.

    Likes: john26, MoKaLux

    +1 -1 (+2 / -0 )Share on Facebook
Sign In or Register to comment.