Disko Forum logo Login  |  Register  |  Lost Password
<< Start < Prev 1 2 Next > End >>
Add a button to a menu

Duran
Posts: 37
graphgraph

Re:Add a button to a menu 6 Years ago  
Hello,

I've test the new code. I'm not very confortable to do two dynamic_cast operations and a search with strings to determine the action to do. IMHO, I think its better to place the buttons to a vertical box and set the proper callback function to each button.

Which are the main differences between a vertical box and a menu?

Joaquim Duran
 
  The administrator has disabled public write access.
Add a button to a menu

Matthias
Posts: 64
graphgraph

Gender: Male Disko Location: Berlin, Germany Birthdate: 1979-04-25
Re:Add a button to a menu 6 Years ago  
Hi Duran,

QUOTE:
I'm not very confortable to do two dynamic_cast operations and a search with strings to determine the action to do.


You're right. It was just an example on how to access the selected menu items.

The first dynamic_cast can be replaced by a static cast, because the
callback is registered for the menu, so it'll always be a menuwidget.

For the rest there are a lot of ways to enhance this. One possibility is, to use the setBinData() to set identifiers (or maybe even function pointers) for every menu item. This way, you can call getBinData(menu->getSelectedItem()) in the callback without casting.

The difference between vbox and menu in handling input is that vboxes don't
handle it. That's why the input is passed to the child widgets. It's no problem to use them, if you prefer it this way. But menus do have a lot of advantages over vboxes.

I hope it becomes more clear to you. If not, feel free to ask further questions.

Best regards,
Matthias
 
  The administrator has disabled public write access.
<< Start < Prev 1 2 Next > End >>
Powered by FireBoard
get the latest posts directly to your desktop