1 // Copyright (C) 2014-2020 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #include <XGUI_ActionsMgr.h>
21 #include <XGUI_ActiveControlMgr.h>
22 #include <XGUI_SelectionActivate.h>
23 #include <XGUI_ActiveControlSelector.h>
24 #include <XGUI_PropertyPanel.h>
25 #include <XGUI_PropertyPanelSelector.h>
26 #include <XGUI_OperationMgr.h>
27 #include <XGUI_Tools.h>
28 #include <XGUI_Workshop.h>
30 //#include <AppElements_Constants.h>
31 #include <ModuleBase_WidgetMultiSelector.h>
32 #include <ModuleBase_Tools.h>
33 #include <ModuleBase_PageBase.h>
34 #include <ModuleBase_PageWidget.h>
35 #include <ModuleBase_WidgetFactory.h>
36 #include <ModuleBase_OperationDescription.h>
37 #include <ModuleBase_Events.h>
38 #include <ModuleBase_IModule.h>
39 #include <ModuleBase_IWorkshop.h>
41 #include <Events_Loop.h>
43 #include <ModelAPI_Session.h>
44 #include <ModelAPI_Validator.h>
50 #include <QLayoutItem>
51 #include <QToolButton>
52 #include <QVBoxLayout>
53 #include <QGridLayout>
56 #include <QScrollArea>
62 //#define DEBUG_TAB_WIDGETS
64 //#define DEBUG_ACTIVE_WIDGET
66 XGUI_PropertyPanel::XGUI_PropertyPanel(QWidget* theParent, XGUI_OperationMgr* theMgr)
67 : ModuleBase_IPropertyPanel(theParent),
70 myPreselectionWidget(NULL),
71 myInternalActiveWidget(NULL),
72 myOperationMgr(theMgr)
74 setWindowTitle(tr("Property Panel"));
75 MAYBE_UNUSED QAction* aViewAct = toggleViewAction();
76 setObjectName(PROP_PANEL);
77 setStyleSheet("::title { position: relative; padding-left: 5px; text-align: left center }");
79 QWidget* aContent = new QWidget(this);
80 QGridLayout* aMainLayout = new QGridLayout(aContent);
81 const int kPanelColumn = 0;
83 aMainLayout->setContentsMargins(3, 3, 3, 3);
86 QFrame* aFrm = new QFrame(aContent);
87 aFrm->setFrameStyle(QFrame::Raised);
88 aFrm->setFrameShape(QFrame::Panel);
89 QHBoxLayout* aBtnLay = new QHBoxLayout(aFrm);
90 ModuleBase_Tools::zeroMargins(aBtnLay);
91 aMainLayout->addWidget(aFrm, aPanelRow++, kPanelColumn);
93 myHeaderWidget = aFrm;
95 QStringList aBtnNames;
96 aBtnNames << QString(PROP_PANEL_HELP)
97 << QString(PROP_PANEL_OK)
98 << QString(PROP_PANEL_OK_PLUS)
99 << QString(PROP_PANEL_CANCEL);
100 foreach(QString eachBtnName, aBtnNames) {
101 QToolButton* aBtn = new QToolButton(aFrm);
102 aBtn->setObjectName(eachBtnName);
103 aBtn->setAutoRaise(true);
104 aBtnLay->addWidget(aBtn);
106 aBtnLay->insertStretch(1, 1);
108 myPanelPage = new ModuleBase_PageWidget(aContent);
109 myPanelPage->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::MinimumExpanding);
110 aMainLayout->addWidget(myPanelPage, aPanelRow, kPanelColumn);
112 // spit to make the preview button on the bottom of the panel
113 aMainLayout->setRowStretch(aPanelRow++, 1);
115 // preview button on the bottom of panel
116 aFrm = new QFrame(aContent);
117 aBtnLay = new QHBoxLayout(aFrm);
118 aBtnLay->addStretch(1);
119 ModuleBase_Tools::zeroMargins(aBtnLay);
120 aMainLayout->addWidget(aFrm, aPanelRow++, kPanelColumn);
122 QToolButton* aBtn = new QToolButton(aFrm);
123 aBtn->setObjectName(PROP_PANEL_PREVIEW);
124 aBtnLay->addWidget(aBtn);
127 XGUI_PropertyPanel::~XGUI_PropertyPanel()
131 void XGUI_PropertyPanel::cleanContent()
134 myActiveWidget->deactivate();
136 XGUI_ActiveControlSelector* aPPSelector = XGUI_Tools::workshop(myOperationMgr->workshop())->
137 activeControlMgr()->getSelector(XGUI_PropertyPanelSelector::Type());
138 aPPSelector->reset(); // it removes need to be updated widget link
140 /// as the widgets are deleted later, it is important that the signals
141 /// of these widgets are not processed. An example of the error is issue 986.
142 /// In the given case, the property panel is firstly filled by new widgets
143 /// of restarted operation and after that the mouse release signal come from
144 /// the widget of the previous operation (Point2d widget about mouse is released
145 /// and focus is out of this widget)
146 QList<ModuleBase_ModelWidget*>::const_iterator anIt = myWidgets.begin(),
147 aLast = myWidgets.end();
148 for (; anIt != aLast; anIt++) {
149 QWidget* aWidget = *anIt;
151 aWidget->blockSignals(true);
156 myPanelPage->clearPage();
157 myActiveWidget = NULL;
158 emit propertyPanelDeactivated();
159 // VSV: It seems that this code is not necessary:
160 // it is called on propertyPanelDeactivated() event
161 //myOperationMgr->workshop()->selectionActivate()->updateSelectionModes();
162 //myOperationMgr->workshop()->selectionActivate()->updateSelectionFilters();
163 #ifdef DEBUG_ACTIVE_WIDGET
164 std::cout << "myActiveWidget = NULL" << std::endl;
167 findButton(PROP_PANEL_PREVIEW)->setVisible(false); /// by default it is hidden
168 setWindowTitle(tr("Property Panel"));
171 void XGUI_PropertyPanel::setModelWidgets(const QList<ModuleBase_ModelWidget*>& theWidgets)
173 myWidgets = theWidgets;
174 if (theWidgets.empty())
176 foreach (ModuleBase_ModelWidget* aWidget, theWidgets) {
177 connect(aWidget, SIGNAL(focusInWidget(ModuleBase_ModelWidget*)),
178 this, SLOT(onFocusInWidget(ModuleBase_ModelWidget*)));
179 connect(aWidget, SIGNAL(focusOutWidget(ModuleBase_ModelWidget*)),
180 this, SLOT(onActivateNextWidget(ModuleBase_ModelWidget*)));
181 connect(aWidget, SIGNAL(keyReleased(QObject*, QKeyEvent*)),
182 this, SIGNAL(keyReleased(QObject*, QKeyEvent*)));
183 connect(aWidget, SIGNAL(enterClicked(QObject*)),
184 this, SIGNAL(enterClicked(QObject*)));
189 const QList<ModuleBase_ModelWidget*>& XGUI_PropertyPanel::modelWidgets() const
194 ModuleBase_PageBase* XGUI_PropertyPanel::contentWidget()
196 return static_cast<ModuleBase_PageBase*>(myPanelPage);
199 void XGUI_PropertyPanel::updateContentWidget(FeaturePtr theFeature)
201 // Invalid feature case on abort of the operation
202 if (theFeature.get() == NULL)
204 if (theFeature->isAction() || !theFeature->data())
206 foreach(ModuleBase_ModelWidget* eachWidget, myWidgets) {
207 if (!eachWidget->feature().get())
208 eachWidget->setFeature(theFeature);
209 eachWidget->restoreValue();
211 // the repaint is used here to immediately react in GUI to the values change.
215 void XGUI_PropertyPanel::createContentPanel(FeaturePtr theFeature)
217 // Invalid feature case on abort of the operation
218 if (theFeature.get() == NULL)
220 if (theFeature->isAction() || !theFeature->data())
223 ModuleBase_Operation* anOperation = myOperationMgr->currentOperation();
224 if (myWidgets.empty()) {
225 QString aXmlRepr = anOperation->getDescription()->xmlRepresentation();
227 ModuleBase_WidgetFactory aFactory(aXmlRepr.toStdString(), myOperationMgr->workshop());
228 ModuleBase_PageBase* aPage = contentWidget();
229 aFactory.createPanel(aPage, theFeature);
230 // update model widgets if exist
231 setModelWidgets(aPage->modelWidgets());
232 // Apply button should be update if the feature was modified by the panel
233 myOperationMgr->onValidateOperation();
235 ModuleBase_OperationFeature* aFeatureOp =
236 dynamic_cast<ModuleBase_OperationFeature*>(anOperation);
237 if (aFeatureOp && (!aFeatureOp->isEditOperation()))
238 updateApplyPlusButton(theFeature);
240 findButton(PROP_PANEL_OK_PLUS)->setVisible(false);
243 void XGUI_PropertyPanel::updateApplyPlusButton(FeaturePtr theFeature)
245 if (theFeature.get()) {
246 std::shared_ptr<Config_FeatureMessage> aFeatureInfo =
247 myOperationMgr->workshop()->featureInfo(theFeature->getKind().c_str());
248 if (aFeatureInfo.get()) {
249 findButton(PROP_PANEL_OK_PLUS)->setVisible(aFeatureInfo->isApplyContinue());
253 findButton(PROP_PANEL_OK_PLUS)->setVisible(false);
256 ModuleBase_ModelWidget* XGUI_PropertyPanel::activeWidget(const bool isUseCustomWidget) const
258 if (isUseCustomWidget && myInternalActiveWidget)
259 return myInternalActiveWidget;
261 return myActiveWidget;
264 void XGUI_PropertyPanel::activateNextWidget(ModuleBase_ModelWidget* theWidget)
266 // it is possible that the property panel widgets have not been visualized
267 // (e.g. on start operation), so it is strictly important to do not check visualized state
268 activateNextWidget(theWidget, false);
271 void XGUI_PropertyPanel::onFocusInWidget(ModuleBase_ModelWidget* theWidget)
273 #ifdef DEBUG_ACTIVE_WIDGET
274 std::cout << "onFocusInWidget" << std::endl;
276 if (theWidget->canAcceptFocus())
277 activateWidget(theWidget);
280 void XGUI_PropertyPanel::onActivateNextWidget(ModuleBase_ModelWidget* theWidget)
282 // this slot happens when some widget lost focus, the next widget which accepts the focus
283 // should be shown, so the second parameter is true
284 // it is important for features where in cases the same attributes are used, isCase for this
285 // attribute returns true, however it can be placed in hidden stack widget(extrusion: elements,
286 // sketch multi rotation -> single/full point)
287 // it is important to check the widget visibility to do not check of the next widget visible
288 // state if the current is not shown. (example: sketch circle re-entrant operation after mouse
289 // release in the viewer, next, radius,
290 // widget should be activated but the first is not visualized)
291 bool isVisible = theWidget->isVisible();
292 activateNextWidget(theWidget, isVisible);
296 void XGUI_PropertyPanel::activateNextWidget(ModuleBase_ModelWidget* theWidget,
297 const bool isCheckVisibility)
299 // TO CHECK: Editing operation does not have automatical activation of widgets
300 if (isEditingMode()) {
301 activateWidget(NULL);
304 ModelAPI_ValidatorsFactory* aValidators = ModelAPI_Session::get()->validators();
306 QList<ModuleBase_ModelWidget*>::const_iterator anIt = myWidgets.begin(), aLast = myWidgets.end();
307 bool isFoundWidget = false;
308 ModuleBase_Tools::activateWindow(this, "XGUI_PropertyPanel::activateNextWidget()");
309 for (; anIt != aLast; anIt++) {
310 ModuleBase_ModelWidget* aCurrentWidget = *anIt;
311 if (isFoundWidget || !theWidget) {
313 if (!aValidators->isCase(aCurrentWidget->feature(), aCurrentWidget->attributeID()))
314 continue; // this attribute does not participate in the current case
315 if (isCheckVisibility && !aCurrentWidget->isInternal()) {
316 if (!aCurrentWidget->isVisible())
319 if (!aCurrentWidget->isObligatory())
320 continue; // not obligatory widgets are not activated automatically
322 if (!aCurrentWidget->canAcceptFocus())
323 continue; // do not set focus if it can not be accepted, case: optional choice
325 if (aCurrentWidget->focusTo()) {
326 aCurrentWidget->emitFocusInWidget();
330 isFoundWidget = isFoundWidget || (*anIt) == theWidget;
332 // set focus to Ok/Cancel button in Property panel if there are no more active widgets
333 // it should be performed before activateWidget(NULL) because it emits some signals which
334 // can be processed by moudule for example as to activate another widget with setting focus
335 QWidget* aNewFocusWidget = 0;
336 QToolButton* anOkBtn = findButton(PROP_PANEL_OK);
337 if (anOkBtn->isEnabled())
338 aNewFocusWidget = anOkBtn;
340 QToolButton* aCancelBtn = findButton(PROP_PANEL_CANCEL);
341 if (aCancelBtn->isEnabled())
342 aNewFocusWidget = aCancelBtn;
345 ModuleBase_Tools::setFocus(aNewFocusWidget, "XGUI_PropertyPanel::activateNextWidget");
347 activateWidget(NULL);
350 void findDirectChildren(QWidget* theParent, QList<QWidget*>& theWidgets, const bool theDebug)
352 QList<QWidget*> aWidgets;
355 QLayout* aLayout = theParent->layout();
357 for (int i = 0, aCount = aLayout->count(); i < aCount; i++) {
358 QLayoutItem* anItem = aLayout->itemAt(i);
359 QWidget* aWidget = anItem ? anItem->widget() : 0;
361 if (aWidget->isVisible()) {
362 if (aWidget->focusPolicy() != Qt::NoFocus)
363 theWidgets.append(aWidget);
364 findDirectChildren(aWidget, theWidgets, false);
367 else if (anItem->layout()) {
368 QLayout* anItemLayout = anItem->layout();
369 for (int it = 0, cnt = anItemLayout->count(); it < cnt; it++) {
370 QLayoutItem* aCurItem = anItemLayout->itemAt(it);
371 QWidget* aCurWidget = aCurItem ? aCurItem->widget() : 0;
373 if (aCurWidget->isVisible()) {
374 if (aCurWidget->focusPolicy() != Qt::NoFocus)
375 theWidgets.append(aCurWidget);
376 findDirectChildren(aCurWidget, theWidgets, false);
380 // TODO: improve recursive search for the case when here QLayout is used
381 // currently, the switch widget uses only 1 level of qlayout in qlayout using for
382 // example for construction plane feature. If there are more levels,
383 // it should be implemented here
390 #ifdef DEBUG_TAB_WIDGETS
392 QStringList aWidgetTypes;
393 QList<QWidget*>::const_iterator anIt = theWidgets.begin(), aLast = theWidgets.end();
394 for (; anIt != aLast; anIt++) {
395 QWidget* aWidget = *anIt;
397 aWidgetTypes.append(aWidget->objectName());
399 QString anInfo = QString("theWidgets[%1]: %2")
400 .arg(theWidgets.count()).arg(aWidgetTypes.join(","));
401 qDebug(anInfo.toStdString().c_str());
406 bool XGUI_PropertyPanel::setFocusNextPrevChild(bool theIsNext)
408 return focusNextPrevChild(theIsNext);
411 bool XGUI_PropertyPanel::focusNextPrevChild(bool theIsNext)
413 // it wraps the Tabs clicking to follow in the chain:
414 // controls, last control, Apply, Cancel, first control, controls
415 bool isChangedFocus = false;
417 QWidget* aFocusWidget = focusWidget();
418 #ifdef DEBUG_TAB_WIDGETS
420 QString anInfo = QString("focus Widget: %1").arg(aFocusWidget->objectName());
421 qDebug(anInfo.toStdString().c_str());
424 ModuleBase_ModelWidget* aFocusMWidget = ModuleBase_ModelWidget::findModelWidget(this,
427 // aFocusMWidget->setHighlighted(false);
429 QWidget* aNewFocusWidget = 0;
431 QList<QWidget*> aChildren;
432 findDirectChildren(this, aChildren, true);
433 int aChildrenCount = aChildren.count();
434 int aFocusWidgetIndex = aChildren.indexOf(aFocusWidget);
435 QToolButton* anOkBtn = findButton(PROP_PANEL_OK);
436 if (aFocusWidgetIndex >= 0) {
438 if (aFocusWidgetIndex == aChildrenCount-1) {
439 // after the last widget focus should be set to "Apply"
440 if (anOkBtn->isEnabled())
441 aNewFocusWidget = anOkBtn;
443 QToolButton* aCancelBtn = findButton(PROP_PANEL_CANCEL);
444 if (aCancelBtn->isEnabled())
445 aNewFocusWidget = aCancelBtn;
449 aNewFocusWidget = aChildren[aFocusWidgetIndex+1];
453 if (aFocusWidgetIndex == 0) {
454 // before the first widget, the last should accept focus
455 aNewFocusWidget = aChildren[aChildrenCount - 1];
458 // before the "Apply" button, the last should accept focus for consistency with "Next"
459 if (aFocusWidget == anOkBtn) {
460 aNewFocusWidget = aChildren[aChildrenCount - 1];
463 aNewFocusWidget = aChildren[aFocusWidgetIndex-1];
469 if (aNewFocusWidget) {
470 if (myActiveWidget) {
471 bool isFirstControl = !theIsNext;
472 QWidget* aLastFocusControl = myActiveWidget->getControlAcceptingFocus(isFirstControl);
473 if (aFocusWidget == aLastFocusControl) {
474 setActiveWidget(NULL, false);
478 // we want to have property panel as an active window to enter values in double control
479 ModuleBase_Tools::setFocus(aNewFocusWidget, "XGUI_PropertyPanel::focusNextPrevChild()");
481 ModuleBase_ModelWidget* aNewFocusMWidget = ModuleBase_ModelWidget::findModelWidget(this,
483 if (aNewFocusMWidget) {
484 if (aFocusMWidget && (aFocusMWidget != aNewFocusMWidget)) {
485 aFocusMWidget->setHighlighted(false);
487 aNewFocusMWidget->emitFocusInWidget();
488 isChangedFocus = true;
491 return isChangedFocus;
494 void XGUI_PropertyPanel::activateNextWidget()
496 activateNextWidget(myActiveWidget);
499 void XGUI_PropertyPanel::activateWidget(ModuleBase_ModelWidget* theWidget, const bool theEmitSignal)
501 std::string aPreviosAttributeID;
503 aPreviosAttributeID = myActiveWidget->attributeID();
505 // Avoid activation of already actve widget. It could happen on focusIn event many times
506 setActiveWidget(theWidget, theEmitSignal);
509 bool XGUI_PropertyPanel::setActiveWidget(ModuleBase_ModelWidget* theWidget, const bool isEmitSignal)
511 // Avoid activation of already actve widget. It could happen on focusIn event many times
512 if (theWidget == myActiveWidget) {
515 std::string aPreviosAttributeID;
516 ModuleBase_ModelWidget* aDeactivatedWidget = NULL, *anActivatedWidget = NULL;
518 aPreviosAttributeID = myActiveWidget->attributeID();
519 myActiveWidget->processValueState();
520 myActiveWidget->deactivate();
521 myActiveWidget->setHighlighted(false);
522 aDeactivatedWidget = myActiveWidget;
525 emit beforeWidgetActivated(theWidget);
526 theWidget->setHighlighted(true);
527 theWidget->activate();
528 anActivatedWidget = theWidget;
530 myActiveWidget = theWidget;
532 #ifdef DEBUG_ACTIVE_WIDGET
533 std::cout << "myActiveWidget = " << (theWidget ? theWidget->context().c_str() : "") << std::endl;
535 bool aHasMoreWidgets = true;
537 //emit widgetActivated(myActiveWidget);
538 if (!myActiveWidget && !isEditingMode()) {
539 aHasMoreWidgets = false;
540 emit noMoreWidgets(aPreviosAttributeID);
544 emit propertyPanelActivated();
546 emit propertyPanelDeactivated();
547 myOperationMgr->workshop()->selectionActivate()->updateSelectionModes();
548 myOperationMgr->workshop()->selectionActivate()->updateSelectionFilters();
550 if (aHasMoreWidgets && aDeactivatedWidget)
551 aDeactivatedWidget->updateAfterDeactivation();
552 if (aHasMoreWidgets && anActivatedWidget)
553 anActivatedWidget->updateAfterActivation();
555 if (aHasMoreWidgets && myActiveWidget)
557 // restore widget selection should be done after selection modes of widget activating
558 static Events_ID anEvent = Events_Loop::eventByName(EVENT_UPDATE_BY_WIDGET_SELECTION);
559 Events_Loop::loop()->flush(anEvent);
564 void XGUI_PropertyPanel::setFocusOnOkButton()
566 QToolButton* anOkBtn = findButton(PROP_PANEL_OK);
567 ModuleBase_Tools::setFocus(anOkBtn, "XGUI_PropertyPanel::setFocusOnOkButton()");
570 void XGUI_PropertyPanel::setCancelEnabled(bool theEnabled)
572 QToolButton* anCancelBtn = findButton(PROP_PANEL_CANCEL);
573 anCancelBtn->setEnabled(theEnabled);
576 bool XGUI_PropertyPanel::isCancelEnabled() const
578 QToolButton* anCancelBtn = findButton(PROP_PANEL_CANCEL);
579 return anCancelBtn->isEnabled();
582 void XGUI_PropertyPanel::setEditingMode(bool isEditing)
584 ModuleBase_IPropertyPanel::setEditingMode(isEditing);
585 foreach(ModuleBase_ModelWidget* aWgt, myWidgets) {
586 aWgt->setEditingMode(isEditing);
590 void XGUI_PropertyPanel::setupActions(XGUI_ActionsMgr* theMgr)
592 QStringList aButtonNames;
593 aButtonNames << PROP_PANEL_OK<< PROP_PANEL_OK_PLUS << PROP_PANEL_CANCEL
594 << PROP_PANEL_HELP << PROP_PANEL_PREVIEW;
595 QList<XGUI_ActionsMgr::OperationStateActionId> aActionIds;
596 aActionIds << XGUI_ActionsMgr::Accept << XGUI_ActionsMgr::AcceptPlus << XGUI_ActionsMgr::Abort
597 << XGUI_ActionsMgr::Help << XGUI_ActionsMgr::Preview;
598 for (int i = 0; i < aButtonNames.size(); ++i) {
599 QToolButton* aBtn = findButton(aButtonNames.at(i).toStdString().c_str());
600 QAction* anAct = theMgr->operationStateAction(aActionIds.at(i));
601 aBtn->setDefaultAction(anAct);
605 void XGUI_PropertyPanel::onAcceptData()
607 foreach (ModuleBase_ModelWidget* aWidget, myWidgets) {
608 aWidget->onFeatureAccepted();
612 void XGUI_PropertyPanel::setInternalActiveWidget(ModuleBase_ModelWidget* theWidget)
616 myInternalActiveWidget = theWidget;
617 emit propertyPanelActivated();
621 if (myInternalActiveWidget)
623 delete myInternalActiveWidget;
624 myInternalActiveWidget = 0;
626 emit propertyPanelDeactivated();
628 myOperationMgr->workshop()->selectionActivate()->updateSelectionModes();
629 myOperationMgr->workshop()->selectionActivate()->updateSelectionFilters();
632 ModuleBase_ModelWidget* XGUI_PropertyPanel::preselectionWidget() const
634 return myPreselectionWidget;
637 void XGUI_PropertyPanel::setPreselectionWidget(ModuleBase_ModelWidget* theWidget)
639 myPreselectionWidget = theWidget;
643 void XGUI_PropertyPanel::closeEvent(QCloseEvent* theEvent)
645 ModuleBase_Operation* aOp = myOperationMgr->currentOperation();
647 if (myOperationMgr->canStopOperation(aOp)) {
648 myOperationMgr->abortOperation(aOp);
649 if (myOperationMgr->hasOperation())
656 ModuleBase_IPropertyPanel::closeEvent(theEvent);
659 QToolButton* XGUI_PropertyPanel::findButton(const char* theInternalName) const
661 return findChild<QToolButton*>(theInternalName);