[Solved] Capture Secondary Mouse button event for TreeView Gadget

Started by _PJ_, November 11, 2023, 12:56:24

Previous topic - Next topic

_PJ_

It seems that there is some "hardcoding" in processing events where using secondary mousebutton for TreeView items sends a "GadgetMenu" event.

This is great and intuitive, since this is typically the process for insdtancing a PopUpWindowMenu context-menu

HOWEVER

There doesn't seem to be a direct means to identify the specific Node which is under the mouse cursor when this is called* - although it seems visdually that the relevant node entry is highlighted brifly, the "SelectedTreeViewNode" always reverts to its prior reference, and therefore can be confusing for end-user if they attempt to openb a context menu for a node that is different from the one previously selected with, say, left-mouse button.


Any ideas on how to work around this, or force a new SelectTreeViewNode() to point to the node that was 'right-clicked'?


* Theroetically some huge computation process could be done to investigate the position and expanded status of an entire list of nodes and calculate their relaive mouse positions

_PJ_

And, typically, once again - no sooner have I posted after struggling for a while, then I manage to solve the issue :D



I am using a select/case switch to process polled events: the relevant event here is, as described, a GadgetMenu event:

Seems GadgetExtra() already identifies the Node gadget, so I just have to force the selection of this cast as a TGadget and everything works just fine!
Code: BASIC
Case EVENT_GADGETMENU
			Select (EventSource())
		Case MYTREEVIEWGADGET
			SelectTreeViewNode(TGadget(EventExtra()))
                        DoPopUpStuff()


Hardcoal

I just found it by myself! and im proud of myself.. shame we need to waste time over such nonsense..
it should be built it or at least have some extra commands.. to make it easier..
but it is what it is as they say.

Code: BASIC
SelectTreeViewNode(TGadget(EventExtra()))

This was very hard to figure out.

The sad thing is that right after i found it.. i searched for a solution on google. and instantly found this thread..
why couldnt i find it before?
maybe god wanted me to solve it by myself..
Things I've done:   https://itch.io/profile/hardcoal  [I keep improving them btw]

Dabz

Always the way... I do it myself a lot where I'll look for something, cannot find the answer, and as soon as I post somewhere about it... Bang... I've worked it out!

It feels like stepping on a chuffing rake!

Dabz
Dell Inspiron 16 Plus 7630 Laptop - 16.0-inch 16:10 2.5K Display, Intel Core i7-13620H Processor, 16 DDR5 RAM, 1, NVIDIA GeForce RTX 4060 GDDR6 Graphics, Windows 11 Piss Flap.