/// <summary> /// 菜单触摸移动方法 /// </summary> /// <param name="item">菜单项</param> /// <param name="touchInfo">触摸信息</param> public virtual void onMenuItemTouchMove(FCMenuItem item, FCTouchInfo touchInfo) { FCNative native = Native; ArrayList <FCMenuItem> items = null; FCMenuItem parentItem = item.ParentItem; if (parentItem != null) { items = parentItem.getItems(); } else { items = m_items; } //关闭其他表格 bool close = closeMenus(items); if (item.getItems().size() > 0) { FCMenu dropDownMenu = item.DropDownMenu; //获取位置和大小 if (dropDownMenu != null) { dropDownMenu.Native = native; FCLayoutStyle layoutStyle = LayoutStyle; FCPoint location = new FCPoint(native.clientX(item) + item.Width, native.clientY(item)); if (layoutStyle == FCLayoutStyle.LeftToRight || layoutStyle == FCLayoutStyle.RightToLeft) { location.x = native.clientX(item); location.y = native.clientY(item) + item.Height; } //设置弹出位置 dropDownMenu.Opacity = Opacity; dropDownMenu.Location = location; dropDownMenu.bringToFront(); dropDownMenu.focus(); dropDownMenu.show(); adjust(dropDownMenu); } } native.invalidate(); }
/// <summary> /// 菜单点击方法 /// </summary> /// <param name="item">菜单项</param> /// <param name="touchInfo">触摸信息</param> public virtual void onMenuItemClick(FCMenuItem item, FCTouchInfo touchInfo) { if (item.getItems().size() == 0) { callMenuItemTouchEvent(FCEventID.MENUITEMCLICK, item, touchInfo); bool close = closeMenus(m_items); if (m_popup) { hide(); } else { Native.invalidate(); } } else { onMenuItemTouchMove(item, touchInfo); } }
/// <summary> /// 关闭网格控件 /// </summary> /// <param name="items">菜单集合</param> /// <returns>是否关闭成功</returns> protected bool closeMenus(ArrayList <FCMenuItem> items) { int itemSize = items.size(); bool close = false; for (int i = 0; i < itemSize; i++) { FCMenuItem item = items.get(i); ArrayList <FCMenuItem> subItems = item.getItems(); if (closeMenus(subItems)) { close = true; } FCMenu dropDownMenu = item.DropDownMenu; if (dropDownMenu != null && dropDownMenu.Visible) { dropDownMenu.hide(); close = true; } } return(close); }
/// <summary> /// 检查图层是否具有焦点 /// </summary> /// <param name="items">控件集合</param> /// <returns>是否有焦点</returns> protected bool checkDivFocused(ArrayList <FCMenuItem> items) { int itemSize = items.size(); for (int i = 0; i < items.size(); i++) { FCMenuItem item = items.get(i); FCMenu dropDownMenu = item.DropDownMenu; if (dropDownMenu != null) { if (checkFocused(dropDownMenu)) { return(true); } } ArrayList <FCMenuItem> subItems = item.getItems(); bool focused = checkDivFocused(subItems); if (focused) { return(true); } } return(false); }