1. Clarence Chamorro
  2. PowerBuilder
  3. Tuesday, 30 October 2018 00:08 AM UTC

I have a window with a menu. I need to change menu item visible property to false or True base on a global variable value. Could you guys guide me to a sample or maybe you can tell how to reference the menu via PB script.

Regards,

Clarence.

Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Tuesday, 30 October 2018 01:12 AM UTC
  2. PowerBuilder
  3. # 1

Hi Clarence;

  You just have to remember that a menu object is a hierarchy of menu item objects. Therefore ...

....visible = FALSE

Tip: Use the PB IDE SystemTree or "Object Browser" to see how many levels to the menu item you need to address is located.

HTH

Regards ... Chris

 

Comment
There are no comments made yet.
René Ullrich Accepted Answer Pending Moderation
  1. Tuesday, 30 October 2018 06:24 AM UTC
  2. PowerBuilder
  3. # 2

The window property MenuId holds a reference to the menu of the window.

So an easy way is:

m_yourmenu lm_menu

lm_menu = this.menuid


lm_menu.m_file.m_open.visible = FALSE
Comment
  1. Clarence Chamorro
  2. Tuesday, 30 October 2018 22:36 PM UTC
Thank you very much. Worked perfect. I appreciate your help Dr.Ulrich.
  1. Helpful
There are no comments made yet.
Konstantinos Laftsidis Accepted Answer Pending Moderation
  1. Wednesday, 12 June 2019 08:54 AM UTC
  2. PowerBuilder
  3. # 3

Hi,

Until yesterday I would answer exactly the same way. However, what happens if the menu item is inherited from a parent menu? Is there a way of changing the visible or toolbaritemvisible property (or any other property) conditionally during run time as Ullrich suggests?

Regards.

Konstantinos

Comment
  1. René Ullrich
  2. Wednesday, 12 June 2019 10:12 AM UTC
I'm not sure what you mean.

If your instance variable is of the same type as your ancestor you can only access the menu items that are defined in the ancestor class but not the items you added in the the descendant. But you will get the item properties of the class you used in the window. If your instance variable is of type of the used (inherited) class you can access all menu items.

If you use conditionally different menus in a window you may write code that conditionally use different variables (lm_menu1, lm_menu2, ...).

Or you write a menu function or event (define in parent menu) that changes the menu item for you. Call this function or event from your window. So you have the logic in your menu and not in your window.
  1. Helpful
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.