core
core copied to clipboard
TextViewSig.Connect can not distinguish left and right click
sig code both is 2. and if right click the right menu always show up.But I want do other thing.
rm := &gi.Menu{} rm.AddAction(gi.ActOpts{Label: "Copy2", ShortcutKey: gi.KeyFunCopy}, ed.This(), func(recv, send ki.Ki, sig int64, data interface{}) {
})
ed.MakeContextMenu(rm)
textview can not self define contextmenu.no Copy2 item in right menu.
I found keyboad input sig is 2, It can not distinguish too. version is newest.
you need to use the lower-level event interface, e.g:
// MouseEvents handles button MouseEvent
func (bb *ButtonBase) MouseEvent() {
bb.ConnectEvent(oswin.MouseEvent, RegPri, func(recv, send ki.Ki, sig int64, d interface{}) {
me := d.(*mouse.Event)
bw := recv.(ButtonWidget)
bbb := bw.AsButtonBase()
if me.Button == mouse.Left {
switch me.Action {
case mouse.DoubleClick: // we just count as a regular click
fallthrough
case mouse.Press:
me.SetProcessed()
bbb.ButtonPress()
case mouse.Release:
me.SetProcessed()
bw.ButtonRelease()
}
}
})
}
added a separate ContextMenu event in V2.