Changing the Look and Feel of the Dialog Close Button


#1

I’ve been trying for a few days but i can’t for the life of me get this thing to work. I’m trying to replace the close button button but overrideing the
createDialogBoxCloseButton() method in my own look and feel object. then set the main dialog windows lookandFeel to my new object.
i was wondering is it even possable to replace the ShapeButton used by the default with an Image Button?

here is an example of my method,

Button* closeStyle::createDialogBoxCloseButton()
{

	ImageButton* const cb = new ImageButton (T("close"));

	cb->setImages(true,false,true,closeNorm,1,Colours::transparentBlack,closeOver,1,Colours::transparentBlack,closeDown,1,Colours::transparentBlack,0.0);
	
	return cb;

}

#2

Yeah, I came up against this in my Pedal Board. What you have to do is call the static LookAndFeel::setDefaultLookAndFeel() method in JUCEApplication::initialise() (not sure if it has to be in initialise()?). Here’s my code:

DialogBoxCloseButton *laf = new DialogBoxCloseButton(); LookAndFeel::setDefaultLookAndFeel(laf);
Where DialogBoxCloseButton is a subclass of the LookAndFeel class (laf = LookAndFeel). I’m not sure if it’s a bug in JUCE that this is the only way to change the DialogWindow’s close button, but it does seem a little strange…

  • Niall.

#3

ah, sorry - that’s a bug in DialogWindow. What it should do is respond to the look and feel change by recreating its close button, but it doesn’t. It’s only a bugette, I’ll sort it out for the next version. Setting the default look and feel is a good workaround in the meantime.


#4

Cool thanks that did the trick

my button does seam to be a bit croped though is there any way to ajust the size and placement of the close button?


#5

never mind i figured it out all you have to do is override the DialogWindow::resize method.


#6