PEDN> Main Web>NPL>ContextMenu (2008-02-29, LiXizhi) Change language en zh-cn? EditAttach

CommonCtrl.ContextMenu

Context menu, using a tree view internally for sub level menus. It has a modern appearance.

Title Context menu, using a tree view internally for sub level menus. It has a modern appearance.
Author(s) LiXizhi
Date 2007/9/24
File script/ide/ContextMenu.lua

Description

Member Functions

ContextMenu:new

 common control library
NPL.load("(gl)script/ide/common_control.lua");
NPL.load("(gl)script/ide/TreeView.lua");
NPL.load("(gl)script/ide/WindowFrame.lua");

 define a new control in the common control libary

 default member attributes
local ContextMenu = {
   -- the top level control name
   name = "ContextMenu1",
   -- normal window size
   width = 400,
   height = 290, 
   -- this is the maximum height, a scroll bar will be used if there are too many menu items. 
   MaxHeight = 500, 
   -- this is the minimum height of the content menu, unless there are so few items to display
   MinHeight = 40, 
   -- auto positioning method: it can be 
   -- "_lt": left top, where the mouse x, y will be the left top point of the menu container. This is the default mode.
   -- "_lb": left bottom, where the mouse x, y will be the left bottom point of the menu container. 
   AutoPositionMode = "_lt", 
   -- the background of container
   container_bg = nil, 
   -- The root tree node. containing all tree node data
   RootNode = nil, 
   -- Default height of Tree Node
   DefaultNodeHeight = 22,
   -- default icon size
   DefaultIconSize = 16,
   -- default indentation
   DefaultIndentation = 16,
   -- Gets or sets a function by which the individual TreeNode control is drawn. The function should be of the format:
   -- function DrawNodeEventHandler(parent,treeNode) end, where parent is the parent container in side which contents should be drawn. And treeNode is the TreeNode object to be drawn
   -- if DrawNode is nil, the default ContextMenu.DrawMenuItemHandler function will be used. 
   DrawNodeHandler = nil,
   -- Force no clipping or always using fast render. Unless you know that the unit scroll step is interger times of all TreeNode height. You can disable clipping at your own risk. 
   -- Software clipping is always used to clip all invisible TreeNodes. However, this option allows you to specify whether to use clipping for partially visible TreeNode. 
   NoClipping = nil,
   -- a function of type function (MenuItem, param1) or nil. this function will be called for each menuitem onclick except the group node.
   onclick = nil,
   -------------------------------------------
   -- private functions
   -------------------------------------------
   IsModified = true,
}
ContextMenu? = ContextMenu;

constructor

syntax

function ContextMenu:new (o)

parameters

o  

ContextMenu:Destroy

Destroy the UI control

syntax

function ContextMenu:Destroy ()

ContextMenu:Show

  • param x : where to display. if nil, mouse_x is used
  • param y : where to display. if nil, mouse_y is used
  • param param1 : a optional parameter object to be passed to onclick event

syntax

function ContextMenu:Show(x, y, param1)

parameters

x where to display. if nil, mouse_x is used
y  
param1 a optional parameter object to be passed to onclick event

ContextMenu:Hide

hide the context menu

syntax

function ContextMenu:Hide()

ContextMenu.OnClose

close the given control

syntax

function ContextMenu.OnClose(sCtrlName)

parameters

sCtrlName  

ContextMenu.OnMouseUpCont

this is a click outside the menu container, we will therefore close the container.

syntax

function ContextMenu.OnMouseUpCont(sCtrlName)

parameters

sCtrlName  

ContextMenu:SetModified

set modified, always call this function after you have changed the menu items. this will cause the content menu to redraw next time it shows up.

syntax

function ContextMenu:SetModified(bModified)

parameters

bModified  

ContextMenu.OnToggleNode

private function: called by default TreeNode? UI

syntax

function ContextMenu.OnToggleNode(sCtrlName, nodePath)

parameters

sCtrlName  
nodePath  

ContextMenu.OnClickNode

private function: called by default TreeNode? UI

syntax

function ContextMenu.OnClickNode(sCtrlName, nodePath)

parameters

sCtrlName  
nodePath  

ContextMenu.DrawMenuItemHandler

default node renderer: it display a clickable check box for expandable node, followed by node text

syntax

function ContextMenu.DrawMenuItemHandler(_parent,treeNode)

parameters

parent  
treeNode  
Topic revision: r1 - 2008-02-29 - 15:26:12 - LiXizhi
 

ParaEngine Developer Network

This site is powered by the TWiki collaboration platformCopyright © 2004-2008 ParaEngine Corporation
Ideas, requests, problems regarding ParaEngine platform Send feedback