mirror of
https://github.com/HeyPuter/puter
synced 2024-11-14 22:06:00 +00:00
Add support for disabled
context menu items through puter.js
This commit is contained in:
parent
04adade80e
commit
ccf6ebef4d
@ -426,6 +426,7 @@ window.addEventListener('message', async (event) => {
|
||||
html: item.label,
|
||||
icon: item.icon ? `<img style="width: 15px; height: 15px; position: absolute; top: 4px; left: 6px;" src="${html_encode(item.icon)}" />` : undefined,
|
||||
icon_active: item.icon_active ? `<img style="width: 15px; height: 15px; position: absolute; top: 4px; left: 6px;" src="${html_encode(item.icon_active)}" />` : undefined,
|
||||
disabled: item.disabled,
|
||||
onClick: () => {
|
||||
if (item.action !== undefined) {
|
||||
item.action();
|
||||
|
@ -261,7 +261,14 @@ function UIContextMenu(options){
|
||||
}
|
||||
});
|
||||
|
||||
// Useful in cases such as where a menu item is over a window, this prevents from the mousedown event
|
||||
// disabled item mousedown event
|
||||
$(`#context-menu-${menu_id} > li.context-menu-item-disabled`).on('mousedown', function (e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
return false;
|
||||
})
|
||||
|
||||
// Useful in cases such as where a menu item is over a window, this prevents the mousedown event from
|
||||
// reaching the window underneath
|
||||
$(`#context-menu-${menu_id} > li:not(.context-menu-item-disabled)`).on('mousedown', function (e) {
|
||||
e.preventDefault();
|
||||
|
Loading…
Reference in New Issue
Block a user