Button Triiger area only in upper third

gui
#1

I’m creating buttons like this:

int  HarmGenEditor::createBut(String Name)
{
	int j = buts.size() + 1;
	static int prex = 80;
	buts.add(new DragAndDropObj());
	buts.getLast()->setBounds(prex, 10, 30, 30);
	buts.getLast()->setButtonText(Name);
	buts.getLast()->changeWidthToFitText();
	buts.getLast()->setTriggeredOnMouseDown(true);
	int pw = buts.getLast()->getWidth();
	addAndMakeVisible(buts.getLast());
	buts.getLast()->setOwner(this);
	prex += pw + 10;
	return j;
}
buts.getLast()->onClick = [this, j] {
	DBG((screens[j]->showMe ? "true" : "false"));
	screens[j]->showMe = !screens[j]->showMe;
	screens[j]->toFront(false);
	screens[j]->setVisible(screens[j]->showMe);

};

The trigger function is only called, when I click in the upper 3rd of the button (i.e. just above the text). Any idea, wha’ts going wrong?

0 Likes

#2

not sure but you can simplify a lot of that:

auto* button = buts.add(new DragAndDropObj());
button->setBounds(...)
button->setButtonText()
button->
//etc..
return buts.size();
0 Likes

#3

Agreed. Hadn’t realize, that add return the pointer to the added item.
But that doesn’t change the problem.

0 Likes

#4

Do you have another Component partially covering the buttons?

0 Likes

#5

Add some DBG statements that print out the bounds of your buttons when they’re clicked. Make sure they’re what you expect. Also if you customized the button so it contains child components, did you turn off mouse interaction for them or add the button as a mouse listener for its children?

0 Likes

#6

Indeed, the file landing zone was obscuring the button. I reduced the zone, and it’s now working as expected. But now, it’s difficult to drag’drop. Can’t the target zone be given a lower priority or something like that?

0 Likes

#7

make your GUI bigger?

0 Likes

#8

It’s already 1100x 1150. Which is obviously too big for a normal screen. And much more so as VST. Maybe I can mark the landing zone with some overlay.

0 Likes