示例#1
0
        internal MenuView(WebContextMenu menu)
        {
            contextMenu = menu;

            Layout = new LinearLayout()
            {
                LinearOrientation = LinearLayout.Orientation.Vertical,
                LinearAlignment   = LinearLayout.Alignment.Center
            };

            texts = new TextLabel[menu.ItemList.ItemCount];

            for (uint i = 0; i < menu.ItemList.ItemCount; i++)
            {
                WebContextMenuItem item = menu.ItemList.GetItemAtIndex(i);
                texts[i] = new TextLabel()
                {
                    Size      = new Size(200, 80),
                    PointSize = 30.0f,
                    TextColor = Color.Black,
                    Text      = item.Title,
                };
                Add(texts[i]);
            }
        }
示例#2
0
 private void OnContextMenuCustomized(object sender, WebViewContextMenuCustomizedEventArgs e)
 {
     Log.Info("WebView", $"------------context menu customized, ItemCount: {e.ContextMenu.ItemCount}-------");
     Log.Info("WebView", $"------------context menu customized, ItemList ItemCount: {e.ContextMenu.ItemList.ItemCount}-------");
     if (e.ContextMenu.ItemList.ItemCount > 0)
     {
         WebContextMenuItem item = e.ContextMenu.ItemList.GetItemAtIndex(0);
         Log.Info("WebView", $"------------context menu customized, Item Tag: {item.Tag}-------");
         Log.Info("WebView", $"------------context menu customized, Item Type: {item.Type}-------");
         Log.Info("WebView", $"------------context menu customized, Item IsEnabled: {item.IsEnabled}-------");
         Log.Info("WebView", $"------------context menu customized, Item LinkUrl: {item.LinkUrl}-------");
         Log.Info("WebView", $"------------context menu customized, Item ImageUrl: {item.ImageUrl}-------");
         Log.Info("WebView", $"------------context menu customized, Item Title: {item.Title}-------");
         if (item.ParentMenu != null)
         {
             Log.Info("WebView", $"------------context menu customized, Item ParentMenu: {item.ParentMenu.ItemCount}-------");
         }
     }
     Log.Info("WebView", $"------------context menu customized, ItemCount: {e.ContextMenu.ItemCount}-------");
     Log.Info("WebView", $"------------context menu customized, Position: {e.ContextMenu.Position}-------");
     e.ContextMenu.AppendItem(WebContextMenuItem.ItemTag.NoAction, "test1", true);
     e.ContextMenu.AppendItem(WebContextMenuItem.ItemTag.NoAction, "test2", "", true);
     e.ContextMenu.Hide();
     if (e.ContextMenu.ItemCount > 0)
     {
         WebContextMenuItem item = e.ContextMenu.GetItemAtIndex(0);
         e.ContextMenu.SelectItem(item);
         e.ContextMenu.RemoveItem(item);
     }
 }
示例#3
0
        public void WebContextMenuItemConstructor()
        {
            tlog.Debug(tag, $"WebContextMenuItemConstructor START");

            using (Tizen.NUI.BaseComponents.WebView webview = new Tizen.NUI.BaseComponents.WebView("Shanghai", "Asia/Shanghai"))
            {
                WebContextMenu menu = new WebContextMenu(webview.SwigCPtr.Handle, false);

                var testingTarget = new WebContextMenuItem(menu.SwigCPtr.Handle, false);
                Assert.IsNotNull(testingTarget, "null handle");
                Assert.IsInstanceOf <WebContextMenuItem>(testingTarget, "Should return WebContextMenuItem instance.");

                menu.Dispose();
                testingTarget.Dispose();
            }

            tlog.Debug(tag, $"WebContextMenuItemConstructor END (OK)");
        }
示例#4
0
        private void OnContextMenuShown(object sender, WebViewContextMenuShownEventArgs e)
        {
            Log.Info("WebView", $"------------context menu is shown, -------");

            if (menuPosition != null)
            {
                menuView = new MenuView(e.ContextMenu)
                {
                    BackgroundColor = Color.Cyan,
                    Position        = new Position(menuPosition),
                    Size            = new Size(200, e.ContextMenu.ItemCount * 80),
                };
                GetDefaultWindow().Add(menuView);
            }

            Log.Info("WebView", $"------------context menu shown, ItemList ItemCount: {e.ContextMenu.ItemList.ItemCount}-------");
            if (e.ContextMenu.ItemList.ItemCount > 0)
            {
                WebContextMenuItem item = e.ContextMenu.ItemList.GetItemAtIndex(0);
                Log.Info("WebView", $"------------context menu shown, Item Tag: {item.Tag}-------");
                Log.Info("WebView", $"------------context menu shown, Item Type: {item.Type}-------");
                Log.Info("WebView", $"------------context menu shown, Item IsEnabled: {item.IsEnabled}-------");
                Log.Info("WebView", $"------------context menu shown, Item LinkUrl: {item.LinkUrl}-------");
                Log.Info("WebView", $"------------context menu shown, Item ImageUrl: {item.ImageUrl}-------");
                Log.Info("WebView", $"------------context menu shown, Item Title: {item.Title}-------");
                if (item.ParentMenu != null)
                {
                    Log.Info("WebView", $"------------context menu shown, ParentMenu item count: {item.ParentMenu.ItemCount}-------");
                }
            }
            Log.Info("WebView", $"------------context menu shown, ItemCount: {e.ContextMenu.ItemCount}-------");
            //Log.Info("WebView", $"------------context menu shown, Position: {e.ContextMenu.Position}-------");
            e.ContextMenu.AppendItem(WebContextMenuItem.ItemTag.NoAction, "test1", true);
            e.ContextMenu.AppendItem(WebContextMenuItem.ItemTag.NoAction, "test2", "", true);
            //e.ContextMenu.Hide();
            if (e.ContextMenu.ItemCount > 0)
            {
                //WebContextMenuItem item = e.ContextMenu.GetItemAtIndex(0);
                //e.ContextMenu.SelectItem(item);
                //e.ContextMenu.RemoveItem(item);
            }
        }