HISE Logo Forum
    • Categories
    • Register
    • Login

    I am definitely doing something stupid with this panel but can't figure out what

    Scheduled Pinned Locked Moved Scripting
    paint routinehovervector
    15 Posts 6 Posters 87 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.
    • R
      rzrsharpeprod @Dan Korneff
      last edited by

      @Dan-Korneff That's interesting as presumably it worked at your end? I tried it on Hise 4.1.0 and the paint routine didn't trigger. Not sure why?

      1 Reply Last reply Reply Quote 0
      • R
        rzrsharpeprod @rglides
        last edited by

        @rglides That changes when I hover over it and also changes colour when I click it so I should be able to look at your code and transpose it to mine, thankyou

        R rglidesR 2 Replies Last reply Reply Quote 0
        • R
          rzrsharpeprod @rzrsharpeprod
          last edited by

          @rzrsharpeprod can I just say, this forum is great as people are very forthcoming with suggestions and help. It is much appreciated and quite rare in a forum I find so thanks everyone

          1 Reply Last reply Reply Quote 2
          • rglidesR
            rglides @rzrsharpeprod
            last edited by

            @rzrsharpeprod yes exactly, you can pick it apart and figure it out

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

              Not sure if you solved it but you have some weird bracket issues going on in your commented out bit.

              Keep else if on the same line

              PnlTestButton.setPaintRoutine(function(g)
              {
                  var a = obj.area;
                  g.drawRoundedRectangle([0, 0, this.getWidth(), this.getHeight()], 3.0, 2);
                  { // What is this curly brace for?
                      if (this.data.hover == 1)
                      {
                          g.setColour(0x50E5EEFF);
                      }
              	    else if (this.data.mouseUp == 1)
              	    {
              		    g.setColour(0x50FFFFFF);
              	    }
                  	else // Missing an opening curly brace, be consistent so all clauses either use braces or don't
              	        g.setColour(0x00);
              	    }
              		} // What's this one for?
              		); // What's this for?	
              }); 
              

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

              R 1 Reply Last reply Reply Quote 1
              • R
                rzrsharpeprod @d.healey
                last edited by

                @d-healey I didn't realise that not having the else if on the same line would make a difference?

                Not sure what is going on with the brackets - I'd copy and pasted stuff in and out so many times I lost the plot in the end I think.

                Regardless I have looked at your code and tidied mine up a bit. It is now firing off to the console as it should off the mouse events with the other code uncommented so thankyou for the assist there.

                I have added further console prints to the paint routine and for some reason it looks like the

                this.data.mouseUp
                

                is never being called.

                this.data.hover
                

                gets called ok and returns "I am hovering" when the mouse event prints "hover" but I never see "I am being clicked" when it prints "click" from tee mouse event.

                Here is my 'cleaned up' code.

                const var PnlTestButton = Content.getComponent("PnlTestButton");
                const var BUTTON_H = 31;
                const var BUTTON_W = 114;
                const var BUTTON_X = 0;
                const var BUTTON_Y = 0;
                
                PnlTestButton.setPaintRoutine(function(g)
                {
                	var buttonArea = [BUTTON_X, BUTTON_Y, BUTTON_W, BUTTON_H];
                	g.drawRoundedRectangle(buttonArea, 4,3);
                	g.setColour(0xFFFE007A);
                	
                		if (this.data.hover==1)
                		{
                			g.setColour(0x50E5EEFF);
                			Console.print("I am hovering");
                		}
                		else if (this.data.mouseUp == 1)
                		{
                			g.setColour(0x50FFFFFF);
                			Console.print("I am being clicked");
                		}
                		else
                		{
                		g.setColour(0x30E5EEFF);
                		}
                	
                }); 
                
                PnlTestButton.setMouseCallback(function(event)
                {
                	if (event.mouseUp ==1)
                	{
                		this.data.mouseUp = event.mouseUp;
                		Console.print("Click");
                		this.repaint();
                		
                	}
                	if (event.hover ==1)
                	{
                		this.data.hover = event.hover; 
                		this.repaint();
                		Console.print("Hover");
                		
                	}
                	else
                	{
                		Console.print("Idle");
                	}
                });
                
                d.healeyD R 2 Replies Last reply Reply Quote 0
                • d.healeyD
                  d.healey @rzrsharpeprod
                  last edited by

                  @rzrsharpeprod said in I am definitely doing something stupid with this panel but can't figure out what:

                  I didn't realise that not having the else if on the same line would make a difference?

                  Logically it doesn't, it just makes it harder to read.

                  @rzrsharpeprod said in I am definitely doing something stupid with this panel but can't figure out what:

                  "I am hovering" when the mouse event prints "hover" but I never see "I am being clicked" when it prints "click" from tee mouse event.

                  You are using else if so that means it will only trigger the this.data.mouseUp part if this.data.hovering is false. You probably need to use two separate ifs instead.

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

                  1 Reply Last reply Reply Quote 0
                  • R
                    rzrsharpeprod @rzrsharpeprod
                    last edited by

                    @rzrsharpeprod as soon as I posted it I realised I needed to switch the order of the hover and the click ifs in the paint routine as the click would never get called because it was always triggering hover.
                    The fact the click is called once and then remains active is an issue for tomorrow but at least that part makes sense now

                    ustkU 1 Reply Last reply Reply Quote 0
                    • ustkU
                      ustk @rzrsharpeprod
                      last edited by

                      @rzrsharpeprod As Dave said. The mouse CB can be tricky sometimes because the order of event you need is often very project dependent. I use it a lot, and I still have to try/fail/succeed until I have no hair anymore and the light can shine through the skull directly, and boom I get it...

                      what can be really helpful is to keep a Console.print(trace(event)); a the top of the CB to understand better the order of events

                      Hise made me an F5 dude, browser just suffers...

                      R 1 Reply Last reply Reply Quote 1
                      • R
                        rzrsharpeprod @ustk
                        last edited by

                        @ustk That's a good shout - I should implement that as part of my logging/troubleshooting as it sounds like good practice. Thankyou

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

                        19

                        Online

                        1.9k

                        Users

                        12.3k

                        Topics

                        107.1k

                        Posts