5
0
mirror of https://github.com/wailsapp/wails.git synced 2025-05-02 18:42:23 +08:00

Fix right mouse button event (#2190)

This commit is contained in:
Lea Anthony 2022-12-13 07:09:45 +11:00 committed by GitHub
parent 38ffbb3161
commit e57bfe002a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 90 additions and 5 deletions

View File

@ -165,7 +165,6 @@ float xroot = 0.0f;
float yroot = 0.0f;
int dragTime = -1;
uint mouseButton = 0;
bool contextMenuDisabled = false;
gboolean buttonPress(GtkWidget *widget, GdkEventButton *event, void* dummy)
{
@ -175,8 +174,8 @@ gboolean buttonPress(GtkWidget *widget, GdkEventButton *event, void* dummy)
return FALSE;
}
mouseButton = event->button;
if( event->button == 3 && contextMenuDisabled ) {
return TRUE;
if( event->button == 3 ) {
return FALSE;
}
if (event->type == GDK_BUTTON_PRESS && event->button == 1)
@ -605,12 +604,15 @@ gboolean UnFullscreen(gpointer data) {
return G_SOURCE_REMOVE;
}
bool disableContextMenu(GtkWindow* window) {
// function to disable the context menu but propogate the event
gboolean disableContextMenu(GtkWidget *widget, WebKitContextMenu *context_menu, GdkEvent *event, WebKitHitTestResult *hit_test_result, gpointer data) {
// return true to disable the context menu
return TRUE;
}
void DisableContextMenu(void* webview) {
contextMenuDisabled = TRUE;
// Disable the context menu but propogate the event
g_signal_connect(WEBKIT_WEB_VIEW(webview), "context-menu", G_CALLBACK(disableContextMenu), NULL);
}

View File

@ -0,0 +1,83 @@
//go:build linux
/*
* Based on code originally from https://github.com/tadvi/systray. Copyright (C) 2019 The Systray Authors. All Rights Reserved.
*/
package systray
import (
"github.com/wailsapp/wails/v2/pkg/menu"
"github.com/wailsapp/wails/v2/pkg/options"
)
type Systray struct {
}
func (p *Systray) Close() {
err := p.Stop()
if err != nil {
println(err.Error())
}
}
func (p *Systray) Update() error {
return nil
}
// SetTitle is unused on Windows
func (p *Systray) SetTitle(_ string) {}
func New() (*Systray, error) {
return nil, nil
}
func (p *Systray) SetMenu(popupMenu *menu.Menu) (err error) {
return
}
func (p *Systray) Stop() error {
return nil
}
func (p *Systray) OnLeftClick(fn func()) {
}
func (p *Systray) OnRightClick(fn func()) {
}
func (p *Systray) OnLeftDoubleClick(fn func()) {
}
func (p *Systray) OnRightDoubleClick(fn func()) {
}
func (p *Systray) OnMenuClose(fn func()) {
}
func (p *Systray) OnMenuOpen(fn func()) {
}
func (p *Systray) SetTooltip(tooltip string) error {
return nil
}
func (p *Systray) Show() error {
return p.setVisible(true)
}
func (p *Systray) Hide() error {
return p.setVisible(false)
}
func (p *Systray) setVisible(visible bool) error {
return nil
}
func (p *Systray) SetIcons(lightModeIcon, darkModeIcon *options.SystemTrayIcon) error {
return nil
}
func (p *Systray) Run() error {
return nil
}