@Chris
Okey I've scanned the autodocs for info about this. To catch IDCMP_MENUVERIFY:
These two need to be set on the window:
WINDOW_IDCMPHook (struct Hook *)
WINDOW_IDCMPHookBits (uint32) IDCMP_MENUVERIFY
Contents of Hook:
struct Hook
{
struct MinNode h_MinNode;
ULONG (*h_Entry)(); /* assembler entry point */
ULONG (*h_SubEntry)(); /* often HLL entry point */
APTR h_Data; /* owner specific */
};
/* Useful definition for casting function pointers:
* hook.h_SubEntry = (HOOKFUNC)AFunction
*/
typedef unsigned long (*HOOKFUNC)();
Contents of MinNode:
struct MinNode
{
struct MinNode *mln_Succ;
struct MinNode *mln_Pred;
};
The prototype for a hook function looks like this:
ULONG HookFunc(struct Hook *hook, APTR object, APTR message);
The IDCMPHook function in particular will be called with these parameters:
uint32 Func(struct Hook *hook, APTR window, struct IntuiMessage *msg)
I must do IDOS->Reply(msg) as quickly as possible (or not?)
To prevent the menu from opening I must do msg->code = MENUCANCEL;
Example code:
struct Hook myIDCMPHook;
myIDCMPHook.mlnNode.mln_Succ = NULL;
myIDCMPHook.mlnNode.mLn_Pred = NULL;
myIDCMPHook.h_Entry = (HOOKFUNC)MyIDCMPHookFunc;
myIDCMPHook.h_SubEntry = NULL;
myIDCMPHook.h_Data = inst; // Just some data
// Part of WindowObject macro:
WINDOW_IDCMPHook, &myIDCMPHook,
WINDOW_IDCMPHookBits, IDCMP_MENUVERIFY,
ULONG MyIDCMPHookFunc(struct Hook *hook, APTR window, struc IntuiMessage *msg)
{
// ...
// Somehow find out which node the pointer was at, if any.
// Mark node as selected
// ...
if(hook->h_Data->allowpopup)
{
msg->code = MENUCANCEL;
IDOS->Reply(msg); // Might not be needed?
// .. open popup menu and do whatever ..
}
else
{
IDOS->Reply(msg); // Might not be needed?
}
return WHOOKRSLT_IGNORE;
}
Unanswered questions:
Can I use msg.IAddress to find out which list browser node that RMB was clicked on?
if not then:
Can I find out which node it was by using msg.MouseX, msg.MouseY ?
Edited by orgin on 2009/3/23 20:53:46
Edited by orgin on 2009/3/23 21:41:12