On & Off button
-
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?
-
@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. -
@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