mirror of
https://github.com/AynaLivePlayer/AynaLivePlayer.git
synced 2025-12-14 14:08:22 +08:00
add configure to prevent wshub event execution.
This commit is contained in:
@@ -1,14 +1,14 @@
|
||||
package xfyne
|
||||
|
||||
import (
|
||||
"fyne.io/fyne/v2"
|
||||
"fyne.io/fyne/v2/widget"
|
||||
"reflect"
|
||||
)
|
||||
|
||||
func EntryDisableUndoRedo(entry *widget.Entry) *widget.Entry {
|
||||
val := reflect.ValueOf(entry).Elem().FieldByName("shortcut").Addr().UnsafePointer()
|
||||
(*fyne.ShortcutHandler)(val).RemoveShortcut(&fyne.ShortcutRedo{})
|
||||
(*fyne.ShortcutHandler)(val).RemoveShortcut(&fyne.ShortcutUndo{})
|
||||
// do nothing because the bug has been fixed in fyne@v2.5.1
|
||||
return entry
|
||||
//val := reflect.ValueOf(entry).Elem().FieldByName("shortcut").Addr().UnsafePointer()
|
||||
//(*fyne.ShortcutHandler)(val).RemoveShortcut(&fyne.ShortcutRedo{})
|
||||
//(*fyne.ShortcutHandler)(val).RemoveShortcut(&fyne.ShortcutUndo{})
|
||||
//return entry
|
||||
}
|
||||
|
||||
@@ -48,7 +48,9 @@ func (c *wsClient) start() {
|
||||
global.Logger.Warn("unmarshal event data failed", err)
|
||||
return
|
||||
}
|
||||
global.EventManager.CallA(data.EventID, actualEventData)
|
||||
if globalEnableWsHubControl {
|
||||
global.EventManager.CallA(data.EventID, actualEventData)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -20,25 +20,31 @@ import (
|
||||
|
||||
type WsHub struct {
|
||||
config.BaseConfig
|
||||
Enabled bool
|
||||
Port int
|
||||
LocalHostOnly bool
|
||||
panel fyne.CanvasObject
|
||||
server *wsServer
|
||||
log logger.ILogger
|
||||
Enabled bool
|
||||
Port int
|
||||
LocalHostOnly bool
|
||||
EnableWsHubControl bool
|
||||
panel fyne.CanvasObject
|
||||
server *wsServer
|
||||
log logger.ILogger
|
||||
}
|
||||
|
||||
func NewWsHub() *WsHub {
|
||||
return &WsHub{
|
||||
Enabled: false,
|
||||
Port: 29629,
|
||||
LocalHostOnly: true,
|
||||
log: global.Logger.WithPrefix("plugin.wshub"),
|
||||
Enabled: false,
|
||||
Port: 29629,
|
||||
LocalHostOnly: true,
|
||||
EnableWsHubControl: false,
|
||||
log: global.Logger.WithPrefix("plugin.wshub"),
|
||||
}
|
||||
}
|
||||
|
||||
var globalEnableWsHubControl = false
|
||||
|
||||
func (w *WsHub) Enable() error {
|
||||
config.LoadConfig(w)
|
||||
// todo: should pass EnableWsHubControl to client instead of using global variable
|
||||
globalEnableWsHubControl = w.EnableWsHubControl
|
||||
w.server = newWsServer(&w.Port, &w.LocalHostOnly)
|
||||
gui.AddConfigLayout(w)
|
||||
w.registerEvents()
|
||||
|
||||
Reference in New Issue
Block a user