HISE Logo Forum
    • Categories
    • Register
    • Login

    On & Off button

    Scheduled Pinned Locked Moved General Questions
    3 Posts 2 Posters 275 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.
    • D
      djalexx1
      last edited by

      Hi, so I ha e buttons that open different t pages, the issue I find is that when I press the on Button it pop up that page and if i press the same button again the button turn off( the button image) the windows still open, so what I need to do so the button image doesn't turn off when I double press the same button?

      A 1 Reply Last reply Reply Quote 0
      • A
        aaronventure @djalexx1
        last edited by aaronventure

        @djalexx1 if you insist on using the button component, you need to add logic to its callback that prevents it from flipping to 0.

        this would be something like

        if (!value) component.setValue(true);
        

        this way if you click on it while its on, the callback value will be 0 and it will automatically set itself back to 1.

        however, if you're saving the component in preset ,the callback will trigger on init, and if your button is at 0, it will automatically flip to 1.

        so now you need to prevent this from happening on init.

        you can define a simple flag that gets set to 1 some time after init and check against that

        var postInit = 0;
        Content.callWithDelay(250, function()
        {
            postInit = 1;
        });
        

        in your callback, the check is now

        if (!value && postInit) component.setValue(true);
        

        @Christoph-Hart
        Do you think you could add a simple method that checks for this? I.e. Engine.isPostInit() so we don't have to do this hacky thing of setting a flag with a delay? I'm not sure this is 100% reliable. You could internally set a variable after processing the init part of the MIDI processor, and the method would simply get that.

        D 1 Reply Last reply Reply Quote 0
        • D
          djalexx1 @aaronventure
          last edited by

          @aaronventure thank u. I tried the first line of code and it worked, so I suppose I will need to add the others because it doesn't let me openthe other wi dows, today I will give it a try again with the other lines

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

          27

          Online

          1.7k

          Users

          11.8k

          Topics

          102.8k

          Posts