I've been trying to open a widget from another widget. The code I have works fine for Foldable theme but not for Launchpad theme.
_showWidget: function (widgetName) {
var wm = WidgetManager.getInstance();
var pm = PanelManager.getInstance();
var myWidget = null;
arrayUtils.some(wm.appConfig.widgetPool.widgets, function (aWidget) {
if (aWidget.name === widgetName) {
myWidget = aWidget;
}
});
if (myWidget) {
var controller = wm.getWidgetsByName("AnchorBarController");
if (controller.length > 0) {
var deferred = pm.showPanel(myWidget);
deferred.then(function (panel) {
//pm.minimizePanel(panel);
pm.normalizePanel(panel);
//pm.maximizePanel(panel);
});
}
else {
pm.showPanel(myWidget);
}
}
},line 17 and 19 both work i.e. they perform as expected, but line 18 does nothing. My panel is still hidden.
Solved! Go to Solution.
Andrew,
When dealing with a widget in the LaunchPads AnchorBar you have to set the panels position:
_showWidget: function (widgetName) {
var wm = WidgetManager.getInstance();
var pm = PanelManager.getInstance();
var myWidget = null;
arrayUtils.some(wm.appConfig.widgetPool.widgets, function (aWidget) {
if (aWidget.name === widgetName) {
myWidget = aWidget;
}
});
if (myWidget) {
var controller = wm.getWidgetsByName("AnchorBarController");
if (controller.length > 0) {
pm.showPanel(myWidget).then(lang.hitch(this, function(panel){
panel.setPosition({ top: 120, left: 10, width: 350, height: 480, margin: 10, index: 0 });
pm.normalizePanel(panel);
}));
} else {
pm.showPanel(myWidget);
}
}
},
Andrew,
When dealing with a widget in the LaunchPads AnchorBar you have to set the panels position:
_showWidget: function (widgetName) {
var wm = WidgetManager.getInstance();
var pm = PanelManager.getInstance();
var myWidget = null;
arrayUtils.some(wm.appConfig.widgetPool.widgets, function (aWidget) {
if (aWidget.name === widgetName) {
myWidget = aWidget;
}
});
if (myWidget) {
var controller = wm.getWidgetsByName("AnchorBarController");
if (controller.length > 0) {
pm.showPanel(myWidget).then(lang.hitch(this, function(panel){
panel.setPosition({ top: 120, left: 10, width: 350, height: 480, margin: 10, index: 0 });
pm.normalizePanel(panel);
}));
} else {
pm.showPanel(myWidget);
}
}
},
Thanks very much, Robert. Works perfectly now.
Edit: someone solved with suggestion to use this.map.height * 0.80 to get a percent value.
Is there any way to specify a percentage for the height/width property?
panel.setPosition({ top: 120, left: 10, width: 350, height: 80%, margin: 10, index: 0 });