1. Faisal Hayat
  2. PowerBuilder
  3. Monday, 19 July 2021 07:57 AM UTC

Hi Folks,

We have a parent menu object with menu items and toolbar items. There are other menu objects which are inherited from the parent menu and being used across the application.

As per recent business change we want to hide/unhide a menu item (m_hidemenu) in parent menu based on a configuration value saved in database.

To achieve above I added a function (mf_set_visibility (ref menu)) in parent menu and added post call, using Edit source, to function (mf_set_visibility) under m_hidemenu.create (Edit source) section of  parent menu object.

Above implementation works fine BUT

If you make another simple change to menu (parent menu) using UI and save it, the code written in m_hidemenu.create section is deleted. 

I understand that PB is rewriting the UI and therefore the custom code in .create is being deleted. I am just wondering is there a way to stop it, it is PB IDE issue or there is no way. Your help, thought and suggestions are highly appreciated.  

 

Regards

Faisal

Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Monday, 19 July 2021 16:00 PM UTC
  2. PowerBuilder
  3. # 1

Hi Faisel;

1) Would not recommend changing PB object by "Editing the Source Code" directly. There are too many ways that you can "shoot yourself in the foot" so to speak.

2) There is no problem adding your own Constructor or PostConstructor as a user event. I have this in my STD Framework's "Base" Menu Ancestor class and drive that event from the "base" Ancestor Window class.I even drive an oe_destructor user event as well for clean-up purposes.

For example:

 

 From the Ancestor menu on "oe_PostOpen" event  ...

IF IsValid (THIS.MenuID) = TRUE THEN // Menu Attached?
   SetPointer (HourGlass!)
   mu_master   lo_mu
   lo_mu    =   THIS.MenuID
   lo_mu.event oe_postconstructor ()
   SetPointer (Arrow!)
END IF

 

HTH

Regards ... Chris

Comment
There are no comments made yet.
René Ullrich Accepted Answer Pending Moderation
  1. Monday, 19 July 2021 08:03 AM UTC
  2. PowerBuilder
  3. # 2

Hi Faisal,

You should not change the internal events create or destroy.

I understand your problem. Usualy the constructor event would be the right place but menus do not have a constructor.

So you can only do a call to your function from outside after the menu was created (e.g. in windows open event).

HTH,

René

 

Comment
  1. Faisal Hayat
  2. Monday, 19 July 2021 08:43 AM UTC
Hi René,

Thanks for your feedback.



Are you a supporter of having a constructor for menu, I think we deserve it. :)



Faisal
  1. Helpful
  1. René Ullrich
  2. Monday, 19 July 2021 08:49 AM UTC
Yes, I think we need a constructor for menu.
  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.
We use cookies which are necessary for the proper functioning of our websites. We also use cookies to analyze our traffic, improve your experience and provide social media features. If you continue to use this site, you consent to our use of cookies.