Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Touch in lower corner of iPad pro misbehaves

edited December 2015 in Bugs Posts: 259

Test program:

-- Touch Test

-- Use this function to perform your initial setup
function setup()
    print("Hello World!")
    back = color(16, 13, 13, 255)
    where = vec2(0,0)
end

function draw()
    background(back)
    strokeWidth(5)
    local t = tostring(where.x) .. ", " .. tostring(where.y)
    text(t, WIDTH/2,HEIGHT/2)    
end

function touched(touch)
    where = vec2(touch.x,touch.y)
    if touch.state == BEGAN then
        back = color(0, 255, 0, 255)
    elseif touch.state == MOVING then
        back = color(255, 255, 0, 255)
    elseif touch.state == ENDED then
        back = color(255,0,0, 255)
    end
end

Touching most anywhere gives a green flash,followed by red, if you pick up, or yellow then red if you drag first.

But touching in lower left hand corner, with x and y less than about 30, you see no green flash, as if there is no BEGAN just ENDED.

Will try in a non Pro iPad Asap, can someone with a Pro please verify? Thanks

(Also, editing in Forum in Codel on Pro seems very messed up. Is that common?)

Thanks!

Comments

  • SimeonSimeon Admin Mod
    Posts: 4,657

    I'll give this a try and see if I can reproduce, thank you for the bug report!

  • Thanks, Simeon, let me know if i can try other stuff for you. I gather you have a Pro to play with?

  • SimeonSimeon Admin Mod
    Posts: 4,657

    I do and I can definitely see what you mean about the touches not picking up in those corners. I'll look into it now.

  • Posts: 148

    I can confirm that the problem also exists on (old) iPad 2. The "dead" rectangle is indeed approximately 0,0,30,30.
    MOVING and ENDED events do work, just BEGAN does not.

  • dave1707dave1707 Mod
    Posts: 7,200

    Using this program with FULLSCREEN_NO_BUTTONS and turning my iPad Air so the corner being tested is the lower left corner, after several tries of touching in the corner of the screen, I can get an x value of 0.0 or 0.5 and a y value of 6.5 or 7.0 in all 4 corners.

    displayMode(FULLSCREEN_NO_BUTTONS)
    
    function setup()
        x,y=-10,-10
    end
    
    function draw()
        background(40, 40, 50)
        fill(255)
        ellipse(x,y,4)
        text(x.."  "..y,WIDTH/2,HEIGHT/2)
    end
    
    function touched(t)
        if t.state==BEGAN or t.state== MOVING then
            x,y=t.x,t.y
        end
    end
    
  • It seems that in new iPad Pro 10.5” 2017 I also cannot press in corners... Only MOVING works.. no BEGIN. Even in FULLSCREEN_NO_BUTTONS.

    But I found one thing. When I press in the corner with two fingers, it works perfectly if second finger not in the corner.
    I think it is defenetly a BUG, and it needs to be fixed.
  • dave1707dave1707 Mod
    Posts: 7,200

    @Compozitor Did you try running the above code and see how close you can get to an edge or a corner.

  • edited December 2017 Posts: 16

    @dave1707 Yes, I get 1.0 7.5 in all corners.

    But BEGIN not working at those coords. Tough I can press it normally with two fingers. Right now it is a solution for me, until it will be fixed. Can someone else confirm it?

  • dave1707dave1707 Mod
    Posts: 7,200

    @Compozitor On my 12.9" iPad Pro, when I use BEGAN, I can get a value of 0 on the left edge, values equal to HEIGHT at the top edge and equal to WIDTH at the right edge. On the bottom edge, I can only get a value of 7.

  • @dave1707 Then maybe it’s a bug with iPad Pro 10.5” 2017 cause it has bigger resolution, then previous model...

  • @dave1707 btw, what do you think, maybe it’s a bug with classes and corners and BEGAN? ;)

  • dave1707dave1707 Mod
    Posts: 7,200

    @Compozitor Here’s another program for you and anyone else with an iPad Pro 10.5” to try. On my iPad Air, the resolution for width is 0 to 768. For height it’s 0 to 1024. Using this program with only BEGAN for touch and touching as close to the edges as I can, I can get an xMin value of 0 on the left edge, a yMax value of 1024 on the top edge, an xMax value of 767.5 on the right edge, and a yMin value of 6.5 on the bottom edge. You can try this and anyone else to see what you get. Just keep touching near an edge for the min and max values.

    displayMode(FULLSCREEN)
    
    function setup()
        tx,ty=0,0
        xMin, xMax,yMin,yMax=9999,0,9999,0
    end
    
    function draw()
        background(40, 40, 50)
        fill(255)
        text("xMin="..xMin,100,HEIGHT/2)
        text("xMax="..xMax,WIDTH-100,HEIGHT/2)
        text("yMin="..yMin,WIDTH/2,100)
        text("yMax="..yMax,WIDTH/2,HEIGHT-100)
        text("width  X=0 to "..WIDTH.."   height  Y=0 to "..HEIGHT,WIDTH/2,HEIGHT/2)
        ellipse(tx,ty,5)
    end
    
    function touched(t)
        if t.state==BEGAN then       
            tx=t.x
            ty=t.y
            if tx>xMax then
                xMax=tx
            end
            if tx<xMin then
                xMin=tx
            end
            if ty>yMax then
                yMax=ty
            end
            if ty<yMin then
                yMin=ty
            end
        end
    end
    
  • edited December 2017 Posts: 16

    @dave1707 Can you please test my code? Try to click with one finger close to the left bottom corner, or opposite.

    Btw in my “Main”, I have settled scale(2,2), noSmooth(), that’s why my everything is doubled in the touch section...
    Sprites are 96,32 px

    Thank you in advance...

    I’m using last iOS version.

    I added sprites. Name them please btn_img and btn_img_2

    Button class:

    Button = class()
    
    function Button:init(name, x, y, flip)
        -- you can accept and set parameters here
        self.name = name
        self.images = {"Project:btn_img", "Project:btn_img_2"}
        self.pos = vec2(x, y)
        self.action = nil
        self.i = 1
        self.flip = flip
        self.w = 96
        self.h = 32
    
         if self.flip then 
            self.w = -self.w
            end
    
    end
    
    function Button:draw()
    
        -- Codea does not automatically call this method   
        spriteMode(CORNER)
    
        if self.selected == true then
        sprite(self.images[2],self.pos.x,self.pos.y, self.w, self.h)
            else
        sprite(self.images[1],self.pos.x,self.pos.y, self.w, self.h)
        end
    end
    
    function Button:touched(t)
        -- Codea does not automantically call this method
        -- print(t.x)
        -- print(t.y)
    
        -- Flipped button
        if self.flip then
           if t.state == BEGAN and
              t.x < self.pos.x*2 and t.x > self.pos.x*2 - math.abs(self.w*2) and
              t.y > self.pos.y*2 and t.y < self.pos.y + self.h*2 then
              self.selected = true   
           end
            if t.state == ENDED and 
               t.x < self.pos.x*2 and t.x > self.pos.x*2 - math.abs(self.w*2) and
               t.y > self.pos.y*2 and t.y < self.pos.y + self.h*2 then
               self.selected = false
               self.action()
            end
        else
        -- Normal button
          if t.state == BEGAN and
             t.x > self.pos.x and t.x < self.pos.x + math.abs(self.w*2) and
             t.y > self.pos.y and t.y < self.pos.y + math.abs(self.h*2) then
             self.selected = true
          end   
           if t.state == ENDED and 
             t.x > self.pos.x and t.x < self.pos.x + math.abs(self.w*2) and
             t.y > self.pos.y and t.y < self.pos.y + math.abs(self.h*2) then
              self.selected = false
              self.action()
           end
        end
    end 
    

    Main:

    function setup()
    
        displayMode(OVERLAY)
        print("Hello World!")
    
        print(WIDTH)
        print(HEIGHT)
    
    
        left_btn = Button("left", 0, 0)
        right_btn = Button("right", WIDTH/2, 0, true)
    
        left_btn.action = function() buttonPressed() end
        right_btn.action = function() buttonPressed2() end
    end
    
    
    -- This function gets called once every frame
    function draw()
        -- This sets a dark background color 
        background(40, 40, 50)
        noSmooth()
        scale(2,2)
        -- This sets the line thickness
        strokeWidth(5)
    
        -- Do your drawing here
        left_btn:draw()
    
        right_btn:draw()
    
    end
    
    function touched(t)
    
        left_btn:touched(t)
    
        right_btn:touched(t)
    
    
    end
    
    function buttonPressed()
        print("Left Button pressed")
    end
    
    function buttonPressed2()
        print("Right Button pressed")
    end
    
  • dave1707dave1707 Mod
    Posts: 7,200

    @Compozitor I get an error on ReadXML. Also, anytime you use your own images, no one else has access to them. If you want others to see images, you either have to use images/sprites that come with Codea or you have to supply the images. Try running the program that I just wrote above to see what values you get for the min and max x and y values. If you can get within a few pixels of the edges with that program but you can’t with your program, then you have an issue with your program.

  • edited December 2017 Posts: 1,045
    Hi all, will check out on my iPad pro later, does this just happen in portrait mode or is it also occuring in landscape.

    This could fit in with my problem with poor response on the bottom left since the intro of ios 11. I suggested a vertical control box option, there were also issues with capturing screen images.
  • @dave1707 I edited code without xml code. And added sprite images. Please test it one more time, and I will test your code right now.

    @Bri_G Thank you! I’m using landscape.

  • @dave1707 I tested your code. At start it shows x=0 y=0. Width = 1112, Hight = 834. When I press on the bottom right corner it’s x=834 and y=6,5.

  • dave1707dave1707 Mod
    Posts: 7,200

    @Bri_G In portrait mode I get xMin of 0 (0), xMax of 767.5 (768), yMin of 6.5 (0) and yMax of 1024 (1024). In landscape mode I get xMin of 0 (0), xMax of 1024 (1024), yMin of 7 (0) and yMax of 768 (768).

  • dave1707dave1707 Mod
    edited December 2017 Posts: 7,200

    @Compozitor I’m not exactly sure what you’re trying to do, but I took your code and made changes to what I think you might be trying to do. If not, let me know and we can change it.

    Edit: Code changed. The buttons are larger and change color when pressed. The buttons were also moved above the 25 pixel error area.

    function setup()
        spriteMode(CORNER)
        textMode(CORNER)
        left_btn = Button("LEFT", 0, 50)
        right_btn = Button("RIGHT", WIDTH-150, 50)
        left_btn.action = function() buttonPressed1() end
        right_btn.action = function() buttonPressed2() end
    end
    
    function draw()
        background(40, 40, 50)
        left_btn:draw()
        right_btn:draw()
    end
    
    function touched(t)
        left_btn:touched(t)
        right_btn:touched(t)
    end
    
    function buttonPressed1()
        print("Left Button pressed")
    end
    
    function buttonPressed2()
        print("Right Button pressed")
    end
    
    Button = class()
    
    function Button:init(name, x, y)
        self.name = name
        self.pos = vec2(x, y)
        self.action = nil
        self.w = 150
        self.h = 75
    end
    
    function Button:draw()
        stroke(255)
        strokeWidth(4)
        fill(0,255,0)
        if self.selected == true then
            fill(255,0,0)
        end
        rect(self.pos.x,self.pos.y, self.w, self.h)
        fill(0,0,255)
        text(self.name,self.pos.x+25,self.pos.y+15)
    end
    
    function Button:touched(t)
        if t.state == BEGAN and
                t.x > self.pos.x and t.x < self.pos.x + math.abs(self.w*2) and
                t.y > self.pos.y and t.y < self.pos.y + math.abs(self.h*2) then
            self.selected = true
            self.action()
        elseif t.state == ENDED and
                t.x > self.pos.x and t.x < self.pos.x + math.abs(self.w*2) and
                t.y > self.pos.y and t.y < self.pos.y + math.abs(self.h*2) then
            self.selected = false
        end 
    end 
    
  • edited December 2017 Posts: 16

    @dave1707 Thank you! Your code is working. But I want sprite to change when I click it. Like a “push” action. And then after ENDED it must back to normal...

    Btw, Did my code worked at your devices?

    The thing is, that all print commands and functions work perfectly wherever I touch, but sprite not changing... only when I press with two fingers or on the right upper corner of the button.

  • dave1707dave1707 Mod
    Posts: 7,200

    @Compozitor I think I found your problem with touching a button near the bottom of the screen. With one of the iOS updates, if you swipe up from the bottom of the screen, the app dock shows. What happens with Codea, the touch doesn’t work properly below 25 pixels. What I see with the program below is, if I touch the red area, the BEGAN touch isn’t recognized. If I touch in the white area, the BEGAN touch is recognized after about 3/4 second. The BEGAN touch is recognized in both areas if I move my finger. @Simeon Is this an iOS problem or a Codea problem.

    displayMode(OVERLAY)
    
    function setup()
    end
    
    function draw()
        background(40, 40, 50)
        fill(255)
        rect(WIDTH/2,0,WIDTH,25)
        fill(255,0,0)
        rect(0,0,WIDTH/2,25)
    end
    
    function touched(t)
        if t.state==BEGAN then
            tx=t.x
            ty=t.y
            print("began  y= ",ty)
        end
        if t.state==MOVING then
            print("moving  x= "..tx.."  ty="..ty)
        end
        if t.state==ENDED then
            print("ended")
        end
    end
    
  • dave1707dave1707 Mod
    Posts: 7,200

    @Compozitor I modified my code a couple of discussions above that changes the color of the button when pressed. I made the buttons larger and moved them above the 25 pixel area that's causing a problem.

  • @dave1707 I tested your code! Yeah I think it was the problem!
    But I cannot touch them on the sides on my iPad 10.5” without moving buttons ~10-13 pixels from borders...

    Thank you for your help, founding what’s wrong!

    About which problem is that... I would be glad to hear it also! And maybe fix it:) Of course I can draw some kind of border there...

  • @dave1707 Just played Grim Fandango Remastered on my iPad Pro 10.5”... It seems that it’s a iOS problem. I cannot touch sides and bottom.
Sign In or Register to comment.