omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    Welcome!

    This is the community forum for my apps Pythonista and Editorial.

    For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.


    Popover location coordinates for button in table row

    Pythonista
    tableviewcell ui.button popover
    3
    4
    1913
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • crazyfox
      crazyfox last edited by

      Hi all-

      I’m trying to present a popover triggered by a button in a TableViewCell.
      My underlying table is a TreeNode (from File Picker) and so I can’t use row_height * row index calculation.
      Converting button.center to screen_coordinates is where I’m getting stuck (I think this is how to accomplish the task)

      Any thoughts?

      cvp mikael 2 Replies Last reply Reply Quote 0
      • cvp
        cvp @crazyfox last edited by cvp

        @crazyfox see how here

        def b_action(sender):
            vi = ObjCInstance(b).view()
            r = vi.convertRect_toView_(vi.bounds(),None)
            # x,y in screen coordinates, not in view
            x,y,w,h = r.origin.x,r.origin.y,r.size.width,r.size.height
            po = ui.View()
            po.frame = (0,0,200,200)
            po.present('popover',popover_location=(x+w/2,y+h)) 
        
        crazyfox 1 Reply Last reply Reply Quote 0
        • crazyfox
          crazyfox @cvp last edited by

          @cvp

          Thank you again for saving my project (and sanity)
          I had read that thread before, but didn’t make the connection.

          Here’s what worked for me:
          I ended up using

          vi = ObjCInstance(b)
          

          Since my object ‘b’ is ui.Button

          Also, the popover location was off by the title bar height. Used GetTitleBarHeight() from here. Adjusted popover padding with help from here.

          I appreciate how helpful this community is. I’m learning a lot.

          1 Reply Last reply Reply Quote 0
          • mikael
            mikael @crazyfox last edited by

            @crazyfox, for future reference, note the convenient ui module functions convert_point and convert_rect.

            1 Reply Last reply Reply Quote 1
            • First post
              Last post
            Powered by NodeBB Forums | Contributors