Skip to content

classes_lib_controls_contextmenu.class

Daniel Spors edited this page Dec 19, 2023 · 2 revisions

Classes in file lib/controls/contextmenu.class.php

class ContextMenu

Wraps a context menu.

Extends: Control » Renderable

AddDefault

To change on of the following defaults menuStyle An object containing styleName:value pairs for styling the containing <ul> menu. itemStyle An object containing styleName:value pairs for styling the <li> elements. itemHoverStyle An object containing styleName:value pairs for styling the hover behaviour of <li> elements. shadow Boolean: display a basic drop shadow on the menu. Defaults to true eventPosX Allows you to define which click event is used to determine where to place the menu. There are possibly times (particularly in IE6) where you will need to set this to "clientX". Defaults to: 'pageX' eventPosY Allows you to define which click event is used to determine where to place the menu. There are possibly times (particularly in IE6) where you will need to set this to "clientY". Defaults to: 'pageY' onContextMenu(event) A custom event function which runs before the context menu is displayed. If the function returns false the menu is not displayed. This allows you to attach the context menu to a large block element (or the entire document) and then filter on right click whether or not the context menu should be shown. onShowMenu(event, menu) A custom event function which runs before the menu is displayed. It is passed a reference to the menu element and allows you to manipulate the output before the menu is shown. This allows you to hide/show options or anything else you can think of before showing the context menu to the user. This function must return the menu.

Definition: public function AddDefault($defaultname, $value)

Returns: void

Parameters:

  • string $defaultname Key to be set

  • string $value The new value

AddMenuItem

Add menuitem to contextmenu $img and title are optional to be able to choose which one is needed. $id is needed to bind functions to menuitems via AddBinding

Definition: public function AddMenuItem($id, $bindingfunction, $title, $img)

Returns: void

Parameters:

  • string $id Elements id

  • string $bindingfunction JS function to bind to click

  • string $title Item title

  • string $img Item icon#

AddTrigger

Specifies a context menu trigger Define one or more jquery-selectors for elements which are uses as triggers for the contextmenu if no trigger is defined the document-selector will be used

Definition: public function AddTrigger($triggerselector)

Returns: void

Parameters:

  • string $triggerselector Valid jQuery selector

BindLeftClick

If called the left-click is also bound. It only works if the menu has one or more triggers

Definition: public function BindLeftClick()

Returns: void

WdfRender

OVERRIDE Prepares JS init code

Clone this wiki locally