[OPEN] [#1556] [4.4.1] Desktop - context menu on Start

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1

    [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:

    @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.

Similar Threads

  1. Changing start menu desktop control
    By ucaneto in forum 3.x Help
    Replies: 1
    Last Post: Jul 08, 2015, 7:52 AM
  2. Programmatically open start menu in desktop
    By markusn in forum 2.x Help
    Replies: 2
    Last Post: Mar 30, 2014, 1:27 PM
  3. Replies: 8
    Last Post: Jul 29, 2012, 10:58 AM
  4. Context Menu in desktop
    By dotnet in forum 1.x Help
    Replies: 7
    Last Post: Sep 16, 2010, 4:30 PM
  5. Context menu on Desktop
    By flaviodamaia in forum 1.x Help
    Replies: 0
    Last Post: May 12, 2009, 9:42 AM

Tags for this Thread

Posting Permissions