-
Hello, I know how to add a new item to the file menu. But now there was a request to REPLACE the menu item with your own. In particular, as many people already know from the questions, I have improved the writing option for viewing files and I need to replace the basic "Show" with the opening of the standard viewer with my own. Please tell me how to do it? Adding item to file menu for example |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 2 replies
-
I will try to make the documentation clearer about it. menu[index] = { label: "your feature".... } and return nothing (otherwise you would be replacing AND adding, you'll see it twice). Anyway, it's a problem to find WHAT item is the show, because the text could be translated. |
Beta Was this translation helpful? Give feedback.
-
in the meantime, you can use this non-perfect method to find the index of the "show" so, the full text would be like |
Beta Was this translation helpful? Give feedback.
-
Yes it would be cool! How the event handler passes the 2nd parameter, the maximum allowed, object / array element, so that the menu can be iterated and found the same one) |
Beta Was this translation helpful? Give feedback.
-
the "menu" is already passed in current version. This is a more complete example: HFS.onEvent('fileMenu', ({ entry, menu }) => {
const index = menu.findIndex(x => x.icon === 'image')
menu[index] = { label: "your feature" }
}) i didn't test it |
Beta Was this translation helpful? Give feedback.
-
cool, but don't include "label: show" when you find, otherwise it won't work when it is translated to another language. |
Beta Was this translation helpful? Give feedback.
the "menu" is already passed in current version. This is a more complete example:
i didn't test it