Help Renaming Tabs Using enterModalState()


#1

Hello,

 

I have been trying to make my tab names editable by following the advice given in this old thread: 

http://www.juce.com/forum/topic/reordering-and-renaming-tabs

 

It posts some code reposted here:


mEditLabel = new CTabLabelTextEditor(T("Tab Label")); 
mTabLabelBeingEdited = tabIndex;
mEditLabel->setText(tabName);
addAndMakeVisible(mEditLabel);
mEditLabel->setBounds(theLabelXPos, Ypos, w, h);
mEditLabel->setSelectAllWhenFocused(true);
mEditLabel->grabKeyboardFocus(); mEditLabel->enterModalState(); //make the editor modal, so clicks outside the box will delete it
mEditLabel->addActionListener(this); //listen to messages from the text editor

When mEditLabel becomes modal, it does not allow any other components on the screen to take mouse messages. I am not sure how his comment "//make the editor modal, so clicks outside the box will delete it" works with this bit of code. Can anyone give advice to allow clicks outside of the modal textbox to end the modal state, and remove mEditLabel from the display?

 

Thanks,

Marko


#2

Hi,

 

False alarm. All of the necessary code was presented. I did not see how it all fit togehter. When you override inputAttemptWhenModal in your textbox subclass, it is called when you click outside of the textbox. From here you can call exitModalState().