3 of 6 rotary sliders don't work

Hi everyone !
I am new to JUCE. I am trying to learn and as you may guessed i have some problems and questions . The code below includes 6 rotary sliders but unfortunately some them don’t work. Everything that i wrote is the same for all of them. Could you please check it and let me know what’s wrong with it ?

https://i.hizliresim.com/Z5PEOg.jpg

__________________________________________________________

#include "MainComponent.h"
//========================================================
MainComponent::MainComponent()
{
dial1.setSliderStyle (Slider::SliderStyle::Rotary);
dial1.setTextBoxStyle(Slider::TextBoxBelow, false, 50, 20);

dial2.setSliderStyle (Slider::SliderStyle::Rotary);
dial2.setTextBoxStyle(Slider::TextBoxBelow, false, 50, 20);

dial3.setSliderStyle (Slider::SliderStyle::Rotary);
dial3.setTextBoxStyle(Slider::TextBoxBelow, false, 50, 20);

dial4.setSliderStyle (Slider::SliderStyle::Rotary);
dial4.setTextBoxStyle(Slider::TextBoxBelow, false, 50, 20);

dial5.setSliderStyle (Slider::SliderStyle::Rotary);
dial5.setTextBoxStyle(Slider::TextBoxBelow, false, 50, 20);

dial6.setSliderStyle (Slider::SliderStyle::Rotary);
dial6.setTextBoxStyle(Slider::TextBoxBelow, false, 50, 20);

addAndMakeVisible(dial1); // this doesnt move
addAndMakeVisible(dial2); // this doesnt move
addAndMakeVisible(dial3);
addAndMakeVisible(dial4);
addAndMakeVisible(dial5); // this doesnt move
addAndMakeVisible(dial6);
setSize (600, 400);
}

MainComponent::~MainComponent()
{
}

//=============================================================
void MainComponent::paint (Graphics& g)
{
g.fillAll(Colours::darkgrey);
}

void MainComponent::resized()
{
Rectangle<int> 
area = getLocalBounds();
Rectangle<int> 
dialArea = area.removeFromBottom(area.getHeight() / 2);// we devided the area which has 
                                                                    //the same bound with the mainwindow                                                      
Rectangle<int>                                         // then we set this area as bound for our 
    slider(dial1).
quarterdial = dialArea.removeFromRight(dialArea.getWidth() / 3);
dial1.setBounds(quarterdial);

area = getLocalBounds();
dialArea = area.removeFromTop(area.getHeight() / 2);
quarterdial = dialArea.removeFromRight(dialArea.getWidth() / 3);
dial2.setBounds(quarterdial);

area = getLocalBounds();
dialArea = area.removeFromTop(area.getHeight() / 2);
dial3.setBounds(area);

area = getLocalBounds();
dialArea = area.removeFromBottom(area.getHeight() / 2);
quarterdial = dialArea.removeFromLeft(dialArea.getWidth() / 3);
dial5.setBounds(quarterdial);

area = getLocalBounds();
dialArea = area.removeFromTop(area.getHeight() / 2);
quarterdial = dialArea.removeFromLeft(dialArea.getWidth() / 3);
dial4.setBounds(quarterdial);

area = getLocalBounds();
dialArea = area.removeFromBottom(area.getHeight() / 2);
dial6.setBounds(area);
}


_________________________________________________________

Maybe your resized() code makes some of the sliders overlap in a way that the mouse events no longer get to some of them.

i have changed resized() section, deleted limitations,… it didn’t work. Now i have another project and the same thing is happening here again.

Here is the file. Can anyone please test it ? There is no an error or warning but it doesnt react.

First, your code formatting is very confusing, I couldn’t follow it. Check the JUCE coding style guide.
Second, just because you can see the component, doesn’t mean they are not overlapping. Your logic is clearly broken.
My general advice is, try harder :wink:

Did you pursue Xenakios’ hint?

Try this resized:

void resized()
{
    auto lowerLine = getLocalBounds();
    auto upperLine = lowerLine.removeFromTop (lowerLine.getHeight() / 2);

    auto third = lowerLine.getWidth() / 3;
    dial1.setBounds (upperLine.removeFromLeft (third));
    dial2.setBounds (upperLine.removeFromLeft (third));
    dial3.setBounds (upperLine);

    dial4.setBounds (lowerLine.removeFromLeft (third));
    dial5.setBounds (lowerLine.removeFromLeft (third));
    dial6.setBounds (lowerLine);
}

(haven’t looked at the rar)

thank you for answers :slight_smile:
as you mentioned it is because of the resized() section. if you look at the rar i have a window which is devided into 3 sections and i was planing to put some stuff(sliders, buttons, LEDs,…) in every each section independently. i put these codes in resized section

void MainComponent::resized()
{
section1.setBounds(getLocalBounds());
//section2.setBounds(getLocalBounds());
//section3.setBounds(getLocalBounds());
 }

Right now it is working.

"just because you can see the component, doesn’t mean they are not overlapping" 

you’re right :slight_smile: