-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Right click to open context menu? #1835
Comments
Thanks for opening this! Yes, I'm surprised it isn't already on the roadmap. Adding it 👍 |
Actually, one can create a context menu using JS. And using wails can perform any action from golang. I believe there are no limitations for this to need something extra, or Is it there? |
@giteshnxtlvl i know, native context menu is much better. @leaanthony i found some waiting options right there wails/v2/pkg/options/options.go Line 69 in f2568f1
do you need help to implement it? i look for "reload" and "inspect element" on context menu but couldn't find it |
I have some old context menu code for Mac that I need to port. The issue is simply this: do we add some features for some platforms and workarounds for others? Or just wait until we can support common functionality across the platforms? It requires a lot of contributions from the community to do the first or else it will end up a fragmented experience. In answer to your question: I'll never turn down offers of help! 👍 I'll give you an insight into the original design and see what you think:
Given that we've registered a context menu called "card-context-menu", we can 'attach' it to the frontend using this data attribute: <div data-wails-context-menu-id='card-context-menu'>
</div>
Example: <div data-wails-context-menu-id='card-context-menu' data-wails-context-menu-data='uuid-of-image'>
</div> The idea is that when a menu is clicked, the callback is triggered but the data is passed back also. This is currently commented out in type CallbackData struct {
MenuItem *MenuItem
//ContextData string
} The JS side looked like this: // Setup context menu hook
window.addEventListener('contextmenu', function (e) {
let currentElement = e.target;
let contextMenuId;
while (currentElement != null) {
contextMenuId = currentElement.dataset['wails-context-menu-id'];
if (contextMenuId != null) {
break;
}
currentElement = currentElement.parentElement;
}
if (contextMenuId != null || window.disableWailsDefaultContextMenu) {
e.preventDefault();
}
if( contextMenuId != null ) {
let contextData = currentElement.dataset['wails-context-menu-data'];
let message = {
id: contextMenuId,
data: contextData || '',
};
window.wailsContextMenuMessage(JSON.stringify(message));
}
}); Q: Why do we have context IDs? Q: Why have the context data? Currently, the context data is a string. I'm wondering whether we should leverage generics for context menus/callbacks so that you can attach arbitrary info (maybe json?) to the element and have it automatically unmarshalled in the callback - not sure yet! I'm open to suggestions on this! If you want to browse the previous (not battle hardened code), then check out the |
@dzpt, What I see is today's application creates context menu design with their branding, Consider slack or vscode... |
@leaanthony i see you put the id on contextmenu. |
Should the context menu be a part of UI framework? For example I am using Quasar and they have that feature: https://quasar.dev/vue-components/menu#context-menu |
Custom Context menus are in v3. Default context menu feature available now in v2 by @mmghv |
Is your feature request related to a problem? Please describe.
I see few app still got reload button while using right click.
any chance to customize this behaviour like vscode?
It would be great to have context menu
Describe the solution you'd like
Don't have
Describe alternatives you've considered
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: