Login
Username:

Password:

Remember me



Lost Password?

Register now!

Sections

Who's Online
117 user(s) are online (110 user(s) are browsing Forums)

Members: 0
Guests: 117

more...

Support us!

Headlines

 
  Register To Post  

(1) 2 »
Popup menus in 4.x
Supreme Council
Supreme Council


See User information
I need a crash course in how to manage popup menus.

Can I use reaction macros to define them?

Is it possible to open a popup menu from a listbrowser?



Anyone got any popup menu examples?

Vacca foeda. Sum, ergo edo

Mr Bobo Cornwater
Go to top
Re: Popup menus in 4.x
Quite a regular
Quite a regular


See User information
@orgin

Does SDK:Documentation/Autodocs/popupmenu_cl.doc answer your questions?

cheers
tony
Go to top
Re: Popup menus in 4.x
Supreme Council
Supreme Council


See User information
@tonyw

Nope. (I've already read that autodoc, I usually read the sdk documentation first then try to find info elsewhere if needed)

Vacca foeda. Sum, ergo edo

Mr Bobo Cornwater
Go to top
Re: Popup menus in 4.x
Quite a regular
Quite a regular


See User information
@orgin

something like that ?

Object pPopUpMenu PMMENU("Menu title"
    
PMITEM("Item 1")
        
PMIA_TitleIDID_ITEM_1,
    
PMEND
    PMITEM
("Item 2")
        
PMIA_TitleIDID_ITEM_2,
    
PMEND
    PMITEM
("Sub menu")
        
PMSUBMENU("SubMenu 1")
            
PMIA_TitleIDID_SUB_ITEM_1,
        
PMEND
        PMSUBMENU
("SubMenu 2")
            
PMIA_TitleIDID_SUB_ITEM_2,
        
PMEND
    PMEND
PMEND

Back to a quiet home... At last
Go to top
Re: Popup menus in 4.x
Supreme Council
Supreme Council


See User information
@abalaban

How do I attach that to a listbrowser/list browser node?

I want to open a popup menu that looks different depending on the type of node. Plus if possible, select the node in the listbrowser.

Vacca foeda. Sum, ergo edo

Mr Bobo Cornwater
Go to top
Re: Popup menus in 4.x
Quite a regular
Quite a regular


See User information
@orgin

You can't, you'll have to do it manually. That's funny I'm currently investigating this for my CompareDir utility
Once you built it, you only have to call its PM_OPEN method.

Back to a quiet home... At last
Go to top
Re: Popup menus in 4.x
Supreme Council
Supreme Council


See User information
@abalaban

Hmm okey, any idea how to catch RMB clicks over a listbrowser?

Vacca foeda. Sum, ergo edo

Mr Bobo Cornwater
Go to top
Re: Popup menus in 4.x
Quite a regular
Quite a regular


See User information
@orgin

Not currently I'm investigating the (ugly IMHO) solution to trap IDCMP_MOUSEBUTTONS and then somehow determine which is the affected node... Not really get further but I have the impression that sometimes agao I read something somewhere in one autodoc that would have permitted me to do this (I just need to remember which one it was)...

Back to a quiet home... At last
Go to top
Re: Popup menus in 4.x
Supreme Council
Supreme Council


See User information
@abalaban

Yeah I tried IDCMP_MOUSEBUTTONS too but I don't get any events from inside the window, only mouse clicks on the intuition parts (window edges, drag bar ect)

Vacca foeda. Sum, ergo edo

Mr Bobo Cornwater
Go to top
Re: Popup menus in 4.x
Supreme Council
Supreme Council


See User information
@abalaban

WA_MenuHook might be an idea. But doesn't seem to be very "nice".

Vacca foeda. Sum, ergo edo

Mr Bobo Cornwater
Go to top
Re: Popup menus in 4.x
Just popping in
Just popping in


See User information
@orgin

Tried to do this myself and have a subclass of listbrowser. Gave up in the end and had to write my own popup class as well.

When I tried I found that PM_Open cannot be called from any callback hooks including WA_MenuHook_- it just locks the OS. You have to use the IDCMP_Flags and trap the RMB.

Guessing here but the reason for the lockup is that PM_Open doesn't return until an item is selected but the OS is waiting for the hook to return before any further messages can be processed.

Go to top
Re: Popup menus in 4.x
Supreme Council
Supreme Council


See User information
These "Intuition" hooks are called in the context of input.device, and while it is sitting there waiting for you to select a menu item, it cannot service any of the other intuition stuff, so the mouse pointer is not updated. The machine has not crashed, it is simply waiting for an event that can never be supplied. The use of hooks such as these requires extreme care. One solution I have adopted is to implement an IPC system that the hook signals the main task in order to use the popup menu. Handling the event is a bit hit and miss too, but I have it working.

Simon

Go to top
Re: Popup menus in 4.x
Supreme Council
Supreme Council


See User information
@madmonkey

Any tip on how to do that?

Putting WA_RMBTrap, TRUE and WA_IDCMP, IDCMP_MOUSEBUTTONS doesn't give me any events inside the window, just in the intuition parts of the window.

Plus of course it kills the program menu which I don't want to.

Vacca foeda. Sum, ergo edo

Mr Bobo Cornwater
Go to top
Re: Popup menus in 4.x
Supreme Council
Supreme Council


See User information
@orgin

Hmm forget that, today I get the events. Must have been very tired last night. Ohh well.

Anyway, the program menu is still dead of course, can I forward the event to input.device somehow? Rigo mentioned something like that, but I have no idea how to do that.

If that's possible I can check if the mouse pointer is above a listbrowser entry (after figuring out how ;), set it to selected and then open the main menu (or a context sensitive popup menu).

Vacca foeda. Sum, ergo edo

Mr Bobo Cornwater
Go to top
Re: Popup menus in 4.x
Amigans Defender
Amigans Defender


See User information

Go to top
Re: Popup menus in 4.x
Supreme Council
Supreme Council


See User information
@Chris

Hmm, that seems nice.

I can't get it to work though. I don't get any such messages in my RA_HandleInput() loop.

Even if I set: WA_IDCMP, IDCMP_MENUVERIFY in the Reaction WindowObject macro.

"If you want to catch the RMB simply set the IDCMP_MENUVERIFY's code field to MENUCANCEL, reply and then take this as an RMB down event."

What does "set the IDCMP_MENUVERIFY's code field" mean? (If it means the message then you don't get a message in a RA_HandleInput() loop, so how can you set something)

How do you reply a message in a RA_HandleInput() loop?

Vacca foeda. Sum, ergo edo

Mr Bobo Cornwater
Go to top
Re: Popup menus in 4.x
Supreme Council
Supreme Council


See User information
@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_IDCMPHookBitsIDCMP_MENUVERIFY,


 
ULONG MyIDCMPHookFunc(struct Hook *hookAPTR windowstruc 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
Vacca foeda. Sum, ergo edo

Mr Bobo Cornwater
Go to top
Re: Popup menus in 4.x
Just popping in
Just popping in


See User information
@orgin

Quote:

Unanswered questions:
What exactly do I put in struct Hook?

Set h_Entry to your hook function, and put whatever you need to access from within the hook function in h_Data.

Quote:

- why are there two function pointers?

h_SubEntry is here for legacy reasons, AFAIR it used to be the glue code for the 68k C ABI. Leave it to NULL.

Quote:

- what is h_MinNode?

Use this if you need to put the hook in a list.
Quote:


- what do I put in h_Data?

See #1.

Edit: There's an example of how to use IDCMPHook in the SDK example of the "hidden chooser".

Go to top
Re: Popup menus in 4.x
Supreme Council
Supreme Council


See User information
@centaurz

Thanks! I've updated my message above with your information.

Vacca foeda. Sum, ergo edo

Mr Bobo Cornwater
Go to top
Re: Popup menus in 4.x
Amigans Defender
Amigans Defender


See User information
@orgin

Ooh, nice to have a working example, as I hadn't actually got round to trying it myself yet!

I'm not sure how you'd find out which item was right-clicked on, you'd probably need to calculate it through the mouse position, or perhaps act the context menu on the last known selected entry, rather than the one it is currently over.

Chris

Go to top

  Register To Post
(1) 2 »

 




Currently Active Users Viewing This Thread: 1 ( 0 members and 1 Anonymous Users )




Powered by XOOPS 2.0 © 2001-2024 The XOOPS Project