mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
added methods for setting the explicit order in which components have their focus traversed, and added jucer support for setting this value
This commit is contained in:
parent
16719685c7
commit
3958257f40
10 changed files with 168 additions and 30 deletions
|
|
@ -154,6 +154,7 @@ XmlElement* ComponentTypeHandler::createXmlFor (Component* comp, const Component
|
|||
e->setAttribute (T("id"), String::toHexString (getComponentId (comp)));
|
||||
e->setAttribute (T("memberName"), comp->getComponentProperty (T("memberName"), false));
|
||||
e->setAttribute (T("virtualName"), comp->getComponentProperty (T("virtualName"), false));
|
||||
e->setAttribute (T("explicitFocusOrder"), comp->getExplicitFocusOrder());
|
||||
|
||||
RelativePositionedRectangle pos (getComponentPosition (comp));
|
||||
pos.updateFromComponent (*comp, layout);
|
||||
|
|
@ -188,6 +189,7 @@ bool ComponentTypeHandler::restoreFromXml (const XmlElement& xml,
|
|||
setComponentId (comp, xml.getStringAttribute (T("id")).getHexValue64());
|
||||
comp->setComponentProperty (T("memberName"), xml.getStringAttribute (T("memberName")));
|
||||
comp->setComponentProperty (T("virtualName"), xml.getStringAttribute (T("virtualName")));
|
||||
comp->setExplicitFocusOrder (xml.getIntAttribute (T("explicitFocusOrder")));
|
||||
|
||||
RelativePositionedRectangle currentPos (getComponentPosition (comp));
|
||||
currentPos.updateFromComponent (*comp, layout);
|
||||
|
|
@ -330,7 +332,6 @@ private:
|
|||
|
||||
String newValue, oldValue;
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
//==============================================================================
|
||||
|
|
@ -370,6 +371,58 @@ private:
|
|||
JucerDocument& document;
|
||||
};
|
||||
|
||||
|
||||
//==============================================================================
|
||||
class FocusOrderProperty : public ComponentTextProperty <Component>
|
||||
{
|
||||
public:
|
||||
FocusOrderProperty (Component* comp, JucerDocument& document)
|
||||
: ComponentTextProperty <Component> (T("focus order"), 8, false, comp, document)
|
||||
{
|
||||
}
|
||||
|
||||
const String getText() const
|
||||
{
|
||||
return String (component->getExplicitFocusOrder());
|
||||
}
|
||||
|
||||
void setText (const String& newText)
|
||||
{
|
||||
document.perform (new SetFocusOrderAction (component, *document.getComponentLayout(), newText.getIntValue()),
|
||||
T("Change focus order"));
|
||||
}
|
||||
|
||||
private:
|
||||
class SetFocusOrderAction : public ComponentUndoableAction <Component>
|
||||
{
|
||||
public:
|
||||
SetFocusOrderAction (Component* const comp, ComponentLayout& layout, const int newOrder_)
|
||||
: ComponentUndoableAction <Component> (comp, layout),
|
||||
newValue (newOrder_)
|
||||
{
|
||||
oldValue = comp->getExplicitFocusOrder();
|
||||
}
|
||||
|
||||
bool perform()
|
||||
{
|
||||
showCorrectTab();
|
||||
getComponent()->setExplicitFocusOrder (newValue);
|
||||
changed();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool undo()
|
||||
{
|
||||
showCorrectTab();
|
||||
getComponent()->setExplicitFocusOrder (oldValue);
|
||||
changed();
|
||||
return true;
|
||||
}
|
||||
|
||||
int newValue, oldValue;
|
||||
};
|
||||
};
|
||||
|
||||
//==============================================================================
|
||||
void ComponentTypeHandler::getEditableProperties (Component* component,
|
||||
JucerDocument& document,
|
||||
|
|
@ -386,6 +439,8 @@ void ComponentTypeHandler::getEditableProperties (Component* component,
|
|||
|
||||
if (dynamic_cast <SettableTooltipClient*> (component) != 0)
|
||||
properties.add (new TooltipProperty (component, document));
|
||||
|
||||
properties.add (new FocusOrderProperty (component, document));
|
||||
}
|
||||
|
||||
void ComponentTypeHandler::addPropertiesToPropertyPanel (Component* comp,
|
||||
|
|
@ -531,6 +586,11 @@ void ComponentTypeHandler::fillInCreationCode (GeneratedCode& code, Component* c
|
|||
<< ");\n";
|
||||
}
|
||||
|
||||
if (component->getExplicitFocusOrder() > 0)
|
||||
s << memberVariableName << "->setExplicitFocusOrder ("
|
||||
<< component->getExplicitFocusOrder()
|
||||
<< ");\n";
|
||||
|
||||
code.constructorCode += s;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue