core icon indicating copy to clipboard operation
core copied to clipboard

TextViewSig.Connect can not distinguish left and right click

Open runsys opened this issue 3 years ago • 1 comments

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.

runsys avatar Feb 06 '22 08:02 runsys

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()
			}
		}
	})
}

rcoreilly avatar Mar 30 '22 05:03 rcoreilly

added a separate ContextMenu event in V2.

rcoreilly avatar Dec 25 '23 01:12 rcoreilly