HISE Logo Forum
    • Categories
    • Register
    • Login

    Lose panel focus when clicking outside

    Scheduled Pinned Locked Moved Feature Requests
    14 Posts 4 Posters 615 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.
    • ustkU
      ustk
      last edited by ustk

      @Christoph-Hart Would it be possible to make the panel to react to mouse click outside of it in order to lose the focus like a label does?

      Currently I'm using a broadcaster, but making every single component to call the bc might not be the better solution if it can be implemented as default panel behaviour in the first place.

      Can't help pressing F5 in the forum...

      VorosMusicV 1 Reply Last reply Reply Quote 1
      • VorosMusicV
        VorosMusic @ustk
        last edited by

        @ustk
        Maybe inverting the idea?
        Tracking a mouse-click and if it's not in a certain area (panel) it's outside?
        Would probably reduce the amount of components.

        And yeah, I agree, might be a nice feature to have.

        ustkU 1 Reply Last reply Reply Quote 2
        • ustkU
          ustk @VorosMusic
          last edited by

          @VorosMusic I don't think a broadcaster can react to a click in the void, and there's currently no mouse event outside of a panel (but I guess this is how a label works)

          Can't help pressing F5 in the forum...

          Christoph HartC 1 Reply Last reply Reply Quote 2
          • Christoph HartC
            Christoph Hart @ustk
            last edited by

            @ustk the entire focus system in JUCE is a bit weird, so I would have to overwrite the focusLost callback in the panel and make it call the mouse event callback with some parameters.

            What‘s the use case? Maybe there‘s a better option.

            ustkU 2 Replies Last reply Reply Quote 1
            • ustkU
              ustk @Christoph Hart
              last edited by ustk

              @Christoph-Hart I see... I have a couple scenario where I use panels to create a label, especially in a child panel context where you can't use a traditional label, and in some cases where you want a label that reacts differently.

              I don't mind using a broadcaster when the UI has a moderate amount of components, although I'm not sure it is clever when there are a lot of them. But I'm might be wrong here, I have no idea if a broadcaster can be CPU greedy in such scenario...

              I also thought of another solution but this doesn't work fo child panels. Make a transparent panel underneath all the "panel labels" and simply use a mouseCB over it that makes all panels losing focus and hides that frankestein, kind of a broadcaster for the poor...

              Losing the focus when clicking outside would definitely be simpler to use, but probably not for you to implement...

              Can't help pressing F5 in the forum...

              1 Reply Last reply Reply Quote 1
              • ustkU
                ustk @Christoph Hart
                last edited by ustk

                @Christoph-Hart What is strange is that it already loses the focus when you click in the code editor for instance or another window (but get it back when you click the interface window again). Couldn't this be transposed to the interface itself?

                Can't help pressing F5 in the forum...

                1 Reply Last reply Reply Quote 1
                • d.healeyD
                  d.healey
                  last edited by

                  What about the ability to add other components to child panels. Would that be a possibility and would it solve the problem?

                  Libre Wave - Freedom respecting instruments and effects
                  My Patreon - HISE tutorials
                  YouTube Channel - Public HISE tutorials

                  ustkU 1 Reply Last reply Reply Quote 1
                  • ustkU
                    ustk @d.healey
                    last edited by

                    @d-healey Yeah this has been asked a while ago, but not sure it can be done... And this would only solve the child panel scenario, not the custom label behaviour

                    Can't help pressing F5 in the forum...

                    Christoph HartC 1 Reply Last reply Reply Quote 2
                    • Christoph HartC
                      Christoph Hart @ustk
                      last edited by

                      What about the ability to add other components to child panels.

                      No that would be catastrophic :)

                      I'll check if I can implement a mouse callback for focus losses, but it's very likely that this messes with existing projects that don't expect such a mouse callback so I need to be super defensive here.

                      ustkU 1 Reply Last reply Reply Quote 1
                      • ustkU
                        ustk @Christoph Hart
                        last edited by ustk

                        @Christoph-Hart Wait! I've just discovered something interesting... the focus is never lost when clicking outside, except if clicked on any panel! Meaning you can show a panel that overlays the whole interface and the focus will be lost instantly when clicking on it, no need for a mouse CB... strange but effective. The only drawback is that it also loses focus when clicking the panel label itself since it is overlayed (but I can think a workaround)

                        Can't help pressing F5 in the forum...

                        Christoph HartC 1 Reply Last reply Reply Quote 1
                        • Christoph HartC
                          Christoph Hart @ustk
                          last edited by

                          @ustk yes the focus only changes when you click on a component that wants the focus itself and the root component of the interface (or a bg image) doesn't want the focus. As I said, it's a bit weird and inconsistent (and especially painful to debug because when you click on a breakpoint in the IDE to inspect the behaviour, the app loses the focus and directly hits the breakpoint).

                          So whatever hack works, go for it!

                          ustkU 1 Reply Last reply Reply Quote 3
                          • ustkU
                            ustk @Christoph Hart
                            last edited by ustk

                            @Christoph-Hart Yeah my hack works.
                            Effectively it is weird because the panel I click is just a stock panel with no behaviour whatsoever, so it shouldn't ask for a focus swap.
                            Although when you click a slider it obviously needs a focus, but doesn't make the focused panel to lose it... Strange... <- I don't know how I've seen this...

                            so just overlaying a panel does it perfectly :thumbs_up:

                            Can't help pressing F5 in the forum...

                            d.healeyD 1 Reply Last reply Reply Quote 2
                            • d.healeyD
                              d.healey @ustk
                              last edited by d.healey

                              @ustk Could you post a snippet that shows the hack? I don't need it (at least at the moment) but it might be useful for future Dave, and other users.

                              Libre Wave - Freedom respecting instruments and effects
                              My Patreon - HISE tutorials
                              YouTube Channel - Public HISE tutorials

                              ustkU 1 Reply Last reply Reply Quote 1
                              • ustkU
                                ustk @d.healey
                                last edited by ustk

                                @d-healey yep it is very straight forward finally...

                                const var focusPnl = Content.getComponent("focusPnl");
                                const var overlayPnl = Content.getComponent("overlayPnl");
                                overlayPnl.showControl(false);
                                
                                
                                focusPnl.setPaintRoutine(function(g)
                                {
                                	g.fillAll(Colours.black);
                                	g.setColour(Colours.antiquewhite);
                                	g.drawAlignedText(this.data.hasFocus ? "HAS FOCUS" : "NOT FOCUSED", this.getLocalBounds(0.0), "centred");
                                });
                                
                                
                                focusPnl.setKeyPressCallback(function(ev)
                                {
                                	if (ev.isFocusChange)
                                	{
                                		this.data.hasFocus = ev.hasFocus;
                                		
                                		// in definitive we just need to toggle the overlay, since the focus loss is made internally...
                                		overlayPnl.showControl(ev.hasFocus);
                                		
                                		this.repaint();
                                	}
                                });
                                
                                HiseSnippet 1012.3ocsV0taaaCEkxNJn1qYXEnO.D9Wx.YF1cccCannNwerYzlDipzh9uBZIJKhPQ5QR4Tug79s2g8Rr2fsKkrrjWb75LvDLLz8ii3gWcuGpoJY.UqkJjSiqWsfhbdrq+JgIdPLgIPSFhb9R2KHZCUgycc9pEDslFhbbp+SVGNMNBkc8mu5bBmHBnktPn2KYAz2vRXlRuS6+ZFmOlDRul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d1Af4aN.LO+.v7sG.lWb.X9tC.y2uWL1O85rTiLIeb.bLcTl9qiyHAA5rx5BQ+Mpcs8rA
                                

                                So as soon as you click the overlay panel, any other panel will lose the focus...
                                You just have to toggle the overlay and bam!
                                If you don't want the focus to be lost when clicking the keypress panel, just use 4 overlay panels that you dynamically place around it instead of using only one that covers the whole interface...

                                Can't help pressing F5 in the forum...

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

                                54

                                Online

                                1.7k

                                Users

                                11.7k

                                Topics

                                101.8k

                                Posts