Forum
    • Categories
    • Register
    • Login

    ScriptLabel.grabFocus()

    Scheduled Pinned Locked Moved Solved Scripting
    13 Posts 2 Posters 41 Views
    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.
    • Oli UllmannO
      Oli Ullmann
      last edited by

      Hi everyone :-)

      If I have ScriptLabel.grabFocus() in a button's callback, shouldn't the corresponding label be brought into focus when I press the button, and shouldn't I be able to start typing right away using the keyboard?

      Or is there something else I need to do here? Or is the function broken?

      Thanks a lot
      Oli

      David HealeyD 1 Reply Last reply Reply Quote 0
      • David HealeyD
        David Healey @Oli Ullmann
        last edited by

        @Oli-Ullmann said in ScriptLabel.grabFocus():

        shouldn't the corresponding label be brought into focus when I press the button, and shouldn't I be able to start typing right away using the keyboard?

        That is what I would expect

        Free HISE Bootcamp Full Course for beginners.
        YouTube Channel - Public HISE tutorials
        My Patreon - HISE tutorials

        Oli UllmannO 1 Reply Last reply Reply Quote 0
        • Oli UllmannO
          Oli Ullmann @David Healey
          last edited by

          @David-Healey
          It didn't work. ChatGPT helped me. Here's how it works:

          Content.callAfterDelay(30, function()
          {
          	ScriptLabel.grabFocus();
          }, this);
          
          David HealeyD 1 Reply Last reply Reply Quote 0
          • Oli UllmannO Oli Ullmann has marked this topic as solved
          • David HealeyD
            David Healey @Oli Ullmann
            last edited by

            @Oli-Ullmann So it works with the callAfterDelay? This looks like a bug that Claude Code could fix.

            Free HISE Bootcamp Full Course for beginners.
            YouTube Channel - Public HISE tutorials
            My Patreon - HISE tutorials

            Oli UllmannO 1 Reply Last reply Reply Quote 0
            • Oli UllmannO
              Oli Ullmann @David Healey
              last edited by

              @David-Healey
              Maybe it's because the label is in a different panel than the button...
              In any case, Content.callAfterDelay was ChatGPT's first suggestion. So I don't know if it's a bug or intended behavior.

              David HealeyD 2 Replies Last reply Reply Quote 0
              • David HealeyD
                David Healey @Oli Ullmann
                last edited by

                @Oli-Ullmann said in ScriptLabel.grabFocus():

                Maybe it's because the label is in a different panel than the button...

                Will need to test

                Free HISE Bootcamp Full Course for beginners.
                YouTube Channel - Public HISE tutorials
                My Patreon - HISE tutorials

                1 Reply Last reply Reply Quote 1
                • David HealeyD
                  David Healey @Oli Ullmann
                  last edited by

                  @Oli-Ullmann It's working here without callAfterDelay. Give this snippet a try.

                  HiseSnippet 944.3ocsV0kaabCDlT1L0RsIHAnOzG2DjGTJBb10RQstEE00xVsBMxQnJMHuEPwkqVBuKovtbchPQAxAHGmbDxwHGhdCZGtjqzp3eRr.pdPfyOey7ogCmQiyTLddtJCga8rEy4H7WQlrPpi6GSERzviP3aQFQy07LOqpCWLmlmyCQX7V+pQAt41nxO+yOeHMgJY7UpPnmqDL9SDoB8JsiO32EIICng7mIRq4c2CFxTx9pDUAvmsH9n4T1ozY7SnF2ZPP+FMOFg+VBk0Iv2uauvNSozog6se2Hdmd85FzIZe+tz8o872ume2.D9FGGJzprIZplmCA8PU3hIwpWIsI34hbwzDtQH.MAxrUMperHIbbUwIGgvaOdUoZKao5qIiDghk5WUxtcoAuUHpWzvMtJJEbMnDtFk11Ro6PlvxDy0qrX3yWRFJgavHJb2TmJVeQMdOlzWAdH06lROkOHCDVhncOe+G5Ae8ferUqG8n658D5TdRPK3pJW6D79Iup.Liq6qRmqjfP66YMeOCzRrGVn0JYEXmzkh1Y2.2cb2biCRclJoOMIYJzezVIcFcFLISHSDRtWTgjoEJo2G6SaVUVdn2YzjB9CZ8WsZJh7ZeWmXylVtu6rL5zAJVQdaHv+cqZg7Dkl+TY6RnfEuO1TTzEZyQgDd1EZ17lH6p.1VVjNkmUm3FGgdf0artwmWiEyV5q4nRNTJzOcN2IOPkDZZXLmOeaHxc2Am9ygGQ0TSmoSG32bdlVXnC9H9Yvr.aeZSxQ77S0p4vy5kW3.k0kVuYUWLUxSPBH06PJOGfdMBSvuAx0ByguAN7JQnN1H7APHlKlEqMRuEY4wxXuy5wt710Ea6MsI1Uih5cvhUB+vAKyw6VKGC.IM+0FhSfRtFlWkA4pdRq3M5Z7qbu5LIrNSDWFSN2u1uvlia4xgs6uLIMItmB1Z48qpk6Yhe9HUJfmlApvMxomwGJGmwgWcl4EW1OO.54GEACAUgEIT85SFM6LbFft50FGYF4HyE5E02obMFW5ekiK+bo3cHiEZV7EywFW.GgJ++Gbzsj4ljiih3L8JBtMYvK1zMJehz+GpBsPNaDUmILcGmTjNAVFy3P1kvEctoQog4MuU12Hap.S3xvRg+E93LFXjwNiAUFQoTVl5kL6rLyZrcJ0.bRVtluI7+M.Yu.T47s504TXq5KYr0C04.t2lBrylBr6lB7waJvdaJvuaSA98eZfl+zyuTnUo1mMHznwGWtP.iOVRgNvxtUz+8xwbyN
                  

                  Peek 2026-03-14 15-04.gif

                  Free HISE Bootcamp Full Course for beginners.
                  YouTube Channel - Public HISE tutorials
                  My Patreon - HISE tutorials

                  Oli UllmannO 2 Replies Last reply Reply Quote 0
                  • Oli UllmannO
                    Oli Ullmann @David Healey
                    last edited by

                    @David-Healey
                    Oh, you used if(!value). That works for me too! :-) Was that on purpose, or was it a mistake?

                    David HealeyD 1 Reply Last reply Reply Quote 0
                    • Oli UllmannO
                      Oli Ullmann @David Healey
                      last edited by

                      @David-Healey
                      Okay, it seems to work sometimes and not others. Because now it's not working again.

                      1 Reply Last reply Reply Quote 0
                      • David HealeyD
                        David Healey @Oli Ullmann
                        last edited by

                        @Oli-Ullmann If it's a momentary button the callback is triggered when you press the button and also when you release the button.

                        Using if (!value) means the action after that line will only be called when you release the mouse.

                        @Oli-Ullmann said in ScriptLabel.grabFocus():

                        Okay, it seems to work sometimes and not others. Because now it's not working again.

                        Make a minimal snippet to demonstrate

                        Free HISE Bootcamp Full Course for beginners.
                        YouTube Channel - Public HISE tutorials
                        My Patreon - HISE tutorials

                        Oli UllmannO 1 Reply Last reply Reply Quote 0
                        • Oli UllmannO
                          Oli Ullmann @David Healey
                          last edited by

                          @David-Healey
                          I found the problem. I also set a text using the button and then I move the focus to the label. That's why it doesn't work. Here's a snippet based on yours:

                          HiseSnippet 954.3ocsV0saaaCElzIbK1asXEXO.p4J0gfV6XGmzMLLO6DuYr5Tu4thdWGMEkEQjHMnnRqwPA5i6tbuAaGJIaQm3rtYrpKr04O98QxyOZhVw3ooJMB23EKWvQ3OmLcozDMHhJjnQmiv2mLllZ3ZuBU8WtfllxCPX7d+fUAt99n7m+765SioRFuREB8RkfwelHQXpzNo2OIhiGRC3uPj33cmdiXJ4.UrJC3ydjlnET1Uz47KoV2pQP+HMMBg+JxogsocOIrM6Tdmi4TZvrS59zfYsa08z1mw6vnzyNoCqySQ3O4h.gQomZnFdJBueeUvxoQp2HK.3khTwrXtUnEZJfbg5gp3.6VzpEMHRDGLY0AUJBVkIUGa6Ubr8kjwh.wZ8UGeeQtAupHbO.w01jd6sA8Z4RulNzaKTB6Po8KnzCHSYZwBSkEKe9LxHIbaFRg6IWpT3Kp1efICTfGRyiSnWwGpAg0Q32sYyi7fedz2znwSdxC8dFcFOtUC3ZK0TJ38sdqVf4by.UxBkDD7Orv7g1PyiselwnjqBtT5NitztM7xWebp0AoQqhGPiimA4J9JYowRCVvDxXgj6ElIYFgR5cSe7YqP4HuqowY7G032aTWD54+vRw5fb8B5aA0+PC+slCOxq3e.i0VmqoyFpXYo9Vsuqw6Z3.6kJC+4R+7kGr3cSSgga0VIMi45sZ1VCo+mBzWlkLiqc2bVGg7jMS9H2cxmasAq35wwQkbjTXd9Bt7tpXPk2ova+5nyoFpMisTG32Bt1HrT.eN+ZneQQ9acx47zqLpEPo+5DAnh1ja8dqxtoRdLR.4vGPxeuE5sUsT9sdKqDNq2aDAln0Jd+U8h3h4QUsldOsmkWqw5fMwJ+RtDqhKbWr55h0WeSrBuEV+bOa5CrgHvwuA50oALcAe09A8eX2erKiBbYj3Cynar6+zBrteIVEUM4fUmTVB4hVeWzF0SjNVk.qCUCpw0RoWyGImn4PAjseycscOFlObqVYPSTUPVL0rYmU67mRCPF+FsyrsrjoByR24S+u0t8eKEe.Yhvvh1NGqsENB0EeL3X4Pp6QtHLjyLUDbexvW8wYhD5WTYFgb9XpQKfrDxkYISgA6LNftDtnscbv0r8FJjaZksm.S4xfbg+BdJM1xJiKM1ZkQTBkoUulUzmyNF7fbM.mj4exPc3aW.YuVn7detmyIvT4WyXatT2Jvi20.auqA1YWC7jcMvt6ZfmtqAd1GNP6GM88YFURQYCBMdxE4CNv3KjTHCLOaE82fr4ydP
                          

                          But with Content.callAfterDelay it is working.

                          David HealeyD 1 Reply Last reply Reply Quote 0
                          • David HealeyD
                            David Healey @Oli Ullmann
                            last edited by

                            @Oli-Ullmann Ah ok, I think changing the text then the focus is probably resetting something when it happens so quickly, so in this instance callAfterDelay is the right approach.

                            Free HISE Bootcamp Full Course for beginners.
                            YouTube Channel - Public HISE tutorials
                            My Patreon - HISE tutorials

                            Oli UllmannO 1 Reply Last reply Reply Quote 1
                            • Oli UllmannO
                              Oli Ullmann @David Healey
                              last edited by

                              @David-Healey
                              As always, thanks a lot, David! :-)

                              1 Reply Last reply Reply Quote 0
                              • First post
                                Last post

                              27

                              Online

                              2.2k

                              Users

                              13.5k

                              Topics

                              117.5k

                              Posts