My TitleBar buttons are disabled


#1

I am create a MainWindow class public DocumentWindow, and my application create a document but buttons minimize, maximize, close are disabled. What can i do to Enable it


#2

Just click in the window to give it focus?


#3

Window has focus and i move it, and buttons are disabled.

MainWindow::MainWindow()
: DocumentWindow (T(“Demo!”),
Colours::ivory,
DocumentWindow::allButtons)
{
centreWithSize (400, 200);
setTitleBarTextCentred(false);
setResizable (true, false);
setVisible (true);
}
It is a class constructor. If my application create an object DocumentWindow - all right,
if create a MainWindow - a doter from DocumentWindow i have this problem…


#4

You shouldn’t inherit from DocumentWindow, you can easily break it by overloading methods that the base class uses. Just use a normal DocumentWindow class and use setContentComponent to give it your content.


#5

Ok, it is work. But i created a MainWindow class from DocumentWindow to overwrite the closeButtonPressed() virtual function. If i create an object DocumentWindow the title bar is Enabled but closeButtonPressed() has no code to delete this object. What can i do?


#6

You could delete the objects in the Destructor of the class. If your class is derived from JUCEApplication you can do it in shutdown().


#7

the problem is that the Window don’t close when i click a close button on TitleBar


#8

I have derived my main window from DocumentWindow many times. I have never had any issues. Please go through this code.

MainWindow::MainWindow ()
	: DocumentWindow (T("XYZ"),
					  Colours::darkgrey,
					  DocumentWindow::allButtons,
					  true)
{
	setResizable (true, false);
	setResizeLimits (400, 300, 8192, 8192);

    MyComponent* const contentComponent = new MyComponent();
    setContentComponent (contentComponent, true, false);
	setVisible (true);
}
//==============================================================================
MainWindow::~MainWindow ()
{
	
}
//=============================================================================
void MainWindow::closeButtonPressed ()
{
	JUCEApplication::getInstance()->systemRequestedQuit();
}

Hopefully it could be useful.


#9

Thank you vishvesh for example, i did what you say, before i did same, but problem dont leave… It is very interesting, i don’t audustent why… When i used

setUsingNativeTitleBar(true);  ---- No problem...? All buttons Enabled and work succesful

#10

Am not very sure, but I believe windows with native title bar are not supposed to have close, minimize and maximize buttons. May be Jules can comment on this.


#11

Sorry, my advice about not inheriting from DocumentWindow was a bit wrong, and vishvesh’s example looks good to me. I’ve really no idea why your buttons wouldn’t work - it sounds like the window isn’t getting focus, so maybe all you need to do is call setWantsKeyboardFocus (true) on your content component?


#12

It’s a little odd, he says if he uses "setUsingNativeTitleBar(true); ", the buttons are enabled. It cannot be focus issues since he can drag the window around but that doesn’t enable the buttons either.


#13

I found a way, i am did that Jules say - i am created a DocumentWindow object in my Application class and wrote a code to close Window when button close clicked, All buttons are work. But if i am create a doter class from DocumentWindow TitleBar is disabled again. May be it is remains a mystery.

One question: i am use setTitleBarTextCentred(false) function for my application MainWindow, how to do that all DialogWindow that will created setTitleBarTextCentred(false) too?


#14

You would have to call “setTitleBarTextCentred(false)” for all the DialogWindow object you create. If you derive your class from DocumentWindow you just have to call “setTitleBarTextCentred(false)” in the constructor of the derived class.


#15

What on earth does “doter class” mean?


#16

Could be a problem with the translator tool.


#17

:smiley: No, i don’t use translator, i am translated from Russian by myself. Sory for bad English… MyWindow : public DocumentWindow MyWindow is “doter” class…

Question: How to get Parent window?


#18

[quote=“Monkol”]:smiley: No, i don’t use translator, i am translated from Russian by myself. Sory for bad English… MyWindow : public DocumentWindow MyWindow is “doter” class…

Question: How to get Parent window?[/quote]

Well you cannot know everything. Your translation is pretty decent had me believe it was through a translator. :slight_smile:

Back to business, “doter class” is the derived class.

[quote=“Monkol”]
But if i am create a doter class from DocumentWindow TitleBar is disabled again.[/quote]

I thing I should have understood it here.

Do you want to call the methods in the parent class ? For calling the base class methods in derived class you can try DocumentWindow::getCloseButton (). If you want it outside the derived class you can use derived class object to call it.


#19

(Did you mean “daughter class”?..)

Anyway, I guess you must be overriding a method in your derived class that’s important to the functionality of the base class.


#20

@Jules,
What is a “daughter class”, never heard of it before? :oops:

@Monkol,
Can you post your mainWindow.h file( mainWindow.cpp would be more helpful )?