[haiku-development] Re: How do I rearrange BMenu items without deleting them?

  • From: John Scipione <jscipione@xxxxxxxxx>
  • To: "haiku-development@xxxxxxxxxxxxx" <haiku-development@xxxxxxxxxxxxx>
  • Date: Sun, 1 Aug 2021 11:47:57 -0400

On Fri, Jul 23, 2021 at 4:51 PM Axel Dörfler <axeld@xxxxxxxxxxxxxxxx> wrote:

There doesn't appear to be a better way to rearrange a menu than to
remove the items into an intermediary list, sort, and add them again.

There isn't, but you know, we control the source, so we could just add
such a method to BMenu. It could even be private for a start.

I added public methods to BMenu to sort, swap, and move menu items in
https://review.haiku-os.org/c/haiku/+/4296

These methods are public because I feel they are useful enough to
warrant being included.

Since BMenu uses a BList to store menu items internally, these methods
simply call into the same methods in BList to do the work.

These methods are non-virtual in BList and so I also made them
non-virtual in BMenu.
Should the methods be virtual? Should the respective methods be
virtual in BList too?

Please go yell at me on the ticket if so, or reply to this and yell at
me if this is bad.

Other related posts: