[haiku-development] Re: Help regarding GSoC idea : Tracker add-on for a version control system

  • From: Rene Gollent <anevilyak@xxxxxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Mon, 26 Mar 2018 14:33:43 -0400

On Mon, Mar 26, 2018 at 2:22 PM, Hrishi Hiraskar
<hrishihiraskar@xxxxxxxxx> wrote:

But now that I can call `populate_menu (entry_ref dir_ref, BMessage *msg,
BMenuItem* item)`,  where I'm passing the BMenuItem of the add on item
created at
https://github.com/Hrily/haiku/blob/63ede39cc8b8149b906969666c0f1bc7ad80193c/src/kits/tracker/ContainerWindow.cpp#L235

I can neither access `item->Submenu()` nor `item->Menu()`. Both turned out
to be null.

A BMenuItem won't have a Submenu() unless it was constructed with one
(c.f. https://git.haiku-os.org/haiku/tree/headers/os/interface/MenuItem.h#n26
). So you may need to make further changes/additions to the API here
in order for you to be able to do that. The Menu() call returns a
pointer to the parent menu that the item is part of in any case, and
it hasn't yet been added to one at the point where this code is being
called, hence getting NULL in both cases. In this case though, since
I'm guessing you want to be able to add items to the top level context
menu itself rather than the add-ons submenu anyways. As such, you may
want to take a slightly different approach here, where either the
add-on API is extended to add another call that can be passed the top
level menu so that the add-on can then manipulate it directly, or
alternatively a call that allows the add-on to return a list of items
rather than being given one up front to modify as was previously the
case.

Regards,

Rene

Other related posts: