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.


    Change Selected Text Color in TableView

    Pythonista
    2
    7
    3437
    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.
    • Enez Houad
      Enez Houad last edited by

      As said in the title, I just want to change the text color and the background color of the selected cell in my custom TableView. No problem for the background color but the text color keep his none selected color …

      Here is my code inside my tableview_cell_for_row def :

      selected_cell = ui.View()
      selected_cell.background_color = (.25, .51, 1.0, 1) 
      selected_cell.text_color = (1, 1, 1, 1.0)
      cell.selected_background_view = selected_cell
      

      Do you see something wrong or is it simply impossible ?

      cvp 1 Reply Last reply Reply Quote 0
      • cvp
        cvp @Enez Houad last edited by

        @Enez-Houad use

        ObjCInstance(cell.text_label).setHighlightedTextColor_(ObjCClass('UIColor').colorWithRed_green_blue_alpha_(1,0,0,0.5))
        

        of course, needs

        from objc_util import *
        
        1 Reply Last reply Reply Quote 0
        • Enez Houad
          Enez Houad last edited by

          All seems possible and so simple with SuperCVP ;-)
          I think I need to try to work on UIKit and ObjC !

          cvp 1 Reply Last reply Reply Quote 0
          • cvp
            cvp @Enez Houad last edited by cvp

            @Enez-Houad Please, don't think that about me, just

            • Google search "uitableview selected color"
            • print(dir(ObjCInstance(cell.text_label)))
            • found setHighlightedTextColor_
              and voilà 😀
            1 Reply Last reply Reply Quote 0
            • Enez Houad
              Enez Houad last edited by

              I throught it was possible to do it directly from Pythonista as changing the selected bg color was possible. I has not the reflex ObjC, I know I should.

              cvp 2 Replies Last reply Reply Quote 0
              • cvp
                cvp @Enez Houad last edited by

                @Enez-Houad do not worry, personally I took more than a year to get this reflex (but I'm old and slow, as my wife says 😂)

                1 Reply Last reply Reply Quote 0
                • cvp
                  cvp @Enez Houad last edited by cvp

                  @Enez-Houad If you want to make your TableView more nice, you can even put an image as background.
                  Assuming tbl is your ui.TableView:

                  ObjCInstance(tbl).setBackgroundView_(ObjCInstance(ui.ImageView(image = ui.Image.named('test:Peppers'), content_mode=ui.CONTENT_SCALE_ASPECT_FILL)))
                  

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