Right-click contextual menus are supported, allowing users to access common operations like copy and paste directly from the context menu. Right-click contextual menus are also supported for additional field types including drop-down lists, pop-up menus, drop-down calendars, and concealed edit boxes, with various UI and state management improvements.
However in my WebDirect solution, they are always disabled:
I don't really understand what Claris was thinking.
I tried a simple test database with one layout and a couple of fields in WebDirect, and on that test database the contextual menus are not disabled, even with running:
I think I figured it out, it seems to be a bug with calculated record Edit privileges.
In this example, the WebDirect [Guest] account has a privilege set where the Record edit permission is set to a calculation (in this case, a simple 0 or 1 based on a Field with Global storage).
In WebDirect...
When edit permission is not allowed, and you try to edit text in a field, you get the error as expected:
Chuck the above code into a custom function, and then put that custom function in a web viewer. hang the WV off the right edge of the layout so it’s at least 1 pixel on-screen so it loads.
This code will execute and enable the standard browser context menu in WebDirect, which includes cut/copy/paste etc.
It only needs to be loaded once from memory, so usually throw it on your start/home layout. I’ve never had any issues with the above code.
the CF only needs to run in WebDirect, so you can either hide the WV in other platforms, or put that logic into the CF
in WebDirect, a WebViewer is implemented as an IFrame (basically like a separate child HTML document inside the parent one.) Inside an iFrame, javascript code can use top.window or top.document to refer back to the parent HTML window and document.
Here's the javascript deconstructed and cleaned up a bit for clarity:
function disableFileMakerContextMenus() {
// if this script has already run before, then bail out
if (top.window.contextMenuOverride) return;
// create a listener function which will be run any time a new node
// is added to the HTML.
top.document.addEventListener ('DOMNodeInserted', (e) =>
{
// e is the event, so we use relatedNote to get the actual node
// oncontextmenu is the eventHandler for when you right-click
// setting it back to 'null' clears out the FileMaker function
e.relatedNode.oncontextmenu = null;
}
);
// the prior code will handle any new nodes
// but we also need to clear out any pre-existing nodes
// so we run the same function as above, but on
// every pre-existing node in the document
// this [...].forEach syntax is a fancy way to say
// for every node in the document, do this...
[...top.document.querySelectorAll('*')].forEach( (el) =>
// clear the context menu handler
el.oncontextmenu = null
);
// set a property on top.window to remind us we have done the task
top.window.contextMenuOverride = true;
}
// run the function
disableFileMakerContextMenus();