-
Notifications
You must be signed in to change notification settings - Fork 298
/
Copy pathContextMenu.d.ts
125 lines (110 loc) · 3.18 KB
/
ContextMenu.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
export declare type ContextMenuConfiguration = {
/** The context menu items. These can also be dynamically set on {@link ContextMenu.items}. See the class documentation for an example. */
items?: any;
/** The context, which is passed into the item callbacks. This can also be dynamically set on {@link ContextMenu.context}. This must be set before calling {@link ContextMenu.show}. */
context?: any;
/** Whether this ````ContextMenu```` is initially enabled. {@link ContextMenu.show} does nothing while this is ````false````. */
enabled?: boolean;
/** Whether this ````ContextMenu```` automatically hides whenever we mouse-down or tap anywhere in the page. */
hideOnMouseDown?: boolean;
};
/**
* A customizable HTML context menu.
*/
export declare class ContextMenu {
/**
* @constructor
*
* @param {ContextMenuConfiguration} [cfg] ````ContextMenu```` configuration.
*/
constructor(cfg?: ContextMenuConfiguration);
/**
* Sets the ````ContextMenu```` items.
*
* These can be updated dynamically at any time.
*
* See class documentation for an example.
*
* @type {Object[]}
*/
set items(arg: any[]);
/**
* Gets the ````ContextMenu```` items.
*
* @type {Object[]}
*/
get items(): any[];
/**
* Sets the ````ContextMenu```` context.
*
* The context can be any object that you need to be provides to the callbacks configured on {@link ContextMenu.items}.
*
* This must be set before calling {@link ContextMenu.show}.
*
* @type {Object}
*/
set context(arg: any);
/**
* Gets the ````ContextMenu```` context.
*
* @type {Object}
*/
get context(): any;
/**
* Sets whether this ````ContextMenu```` is enabled.
*
* Hides the menu when disabling.
*
* @type {Boolean}
*/
set enabled(arg: boolean);
/**
* Gets whether this ````ContextMenu```` is enabled.
*
* {@link ContextMenu.show} does nothing while this is ````false````.
*
* @type {Boolean}
*/
get enabled(): boolean;
/**
Subscribes to an event fired at this ````ContextMenu````.
@param {String} event The event
@param {Function} callback Callback fired on the event
*/
on(event: string, callback: Function): void;
/**
Fires an event at this ````ContextMenu````.
@param {String} event The event type name
@param {Object} value The event parameters
*/
fire(event: string, value: any): void;
/**
* Shows this ````ContextMenu```` at the given page coordinates.
*
* Does nothing when {@link ContextMenu.enabled} is ````false````.
*
* Logs error to console and does nothing if {@link ContextMenu.context} has not been set.
*
* Fires a "shown" event when shown.
*
* @param {Number} pageX Page X-coordinate.
* @param {Number} pageY Page Y-coordinate.
*/
show(pageX: number, pageY: number): void;
/**
* Gets whether this ````ContextMenu```` is currently shown or not.
*
* @returns {Boolean} Whether this ````ContextMenu```` is shown.
*/
get shown(): boolean;
/**
* Hides this ````ContextMenu````.
*
* Fires a "hidden" event when hidden.
*/
hide(): void;
/**
* Destroys this ````ContextMenu````.
*/
destroy(): void;
}