Sep 13, 2017, 5:50 AM
[OPEN] [#1556] [4.4.1] Desktop - context menu on Start
Hello support team,
when searching for a suitable solution for creating a desktop shortcut from the start menu item, I tested also the possibility to use the context menu for this purpose. Implementation is simple, but is the behaviour correct? Even with AllowOtherMenus(true) the start menu is hidden when it loses focus:
Thank you.
Dan
when searching for a suitable solution for creating a desktop shortcut from the start menu item, I tested also the possibility to use the context menu for this purpose. Implementation is simple, but is the behaviour correct? Even with AllowOtherMenus(true) the start menu is hidden when it loses focus:
@using Ext.Net;
@using Ext.Net.MVC;
@{
ViewBag.Title = "Context Menu on Desktop Start Example";
Layout = null;
var X = Html.X();
List<MenuItem> startMenu = new List<Ext.Net.MenuItem>();
startMenu.Add(new Ext.Net.MenuItem() { ID = "EU", Icon = Icon.FlagEuropeanunion, Text = "European Union", ContextMenuID = "_nelisDesktop_ContextMenu" });
startMenu.Add(new Ext.Net.MenuItem() { ID = "US", Icon = Icon.FlagUs, Text = "United States", ContextMenuID = "_nelisDesktop_ContextMenu" });
}
<!DOCTYPE html>
<html>
<head>
<title>Ext.NET MVC Test Case</title>
<script type="text/javascript">
var itemClicked;
function startReady() {
Ext.get("EU").on('contextmenu', function (e) { itemClicked = e.currentTarget.id; });
Ext.get("US").on('contextmenu', function (e) { itemClicked = e.currentTarget.id; });
}
</script>
</head>
<body>
@Html.X().ResourceManager()
@(Html.X().Menu()
.ID("_nelisDesktop_ContextMenu").AllowOtherMenus(true)
.TitleAlign(TitleAlign.Center)
.Items(
Html.X().MenuItem()
.ID("_nelisUserMenu_ContextMenuRenamePanel")
.Icon(Icon.TableRefresh)
.Text("Create Shortcut")
.Listeners(l => l.Click.Handler = "console.log('Create ShortCut:', itemClicked)")
)
)
@(Html.X().Desktop()
.ID("_nelisDesktop")
.DesktopConfig(
Html.X().DesktopConfig()
.SortShortcuts(true)
.WallpaperStretch(true)
.ShortcutDragSelector(true)
)
.StartMenu(
Html.X().DesktopStartMenu()
.ID("_nelisDesktop_StartMenu")
.Title("Allegro Desktop")
.Icon(Icon.Application)
.MenuItems(startMenu)
.Listeners(l => l.AfterRender.Fn = "startReady")
)
)
</body>
</html>
A small sub-question: is there a more reliable way to get an item on which the context menu was triggered? Using e.currentTarget.id seems to me too tricky.Thank you.
Dan
Last edited by fabricio.murta; Oct 02, 2017 at 6:41 PM.