1. Louis Arena
  2. PowerBuilder
  3. Thursday, 2 May 2024 16:44 PM UTC

I am working on customizing a menu.  One of  the menu choices is called Favorites, and you can have up to 9 favorite items in this submenu.  I have a function that will rename the 9 items and make them visible (if you only have 6 then only 6 are visible).  Your favorite is stored in an array that contains the menu option you want to select.

For example, variable gm_menu_favs[1] = m_mdi_frame.m_report.m_all_sales.  The menu text Favorites\Favorite1 has been changed to Sales Report.

 

When Favorites\Sales Report is selected, in the clicked event I want to execute this script.

 

gm_menu_favs[1].triggerevent(Clicked!)

 

however this will not work as it says "Invalid operand type for Dot operator:string

 

Makes sense, but how do I create a menu object and identifiy the menu item I want to trigger?

 

this also does not work.

menu lm_this
lm_this = this

lm_this.gs_menu_favs[1].triggerevent(Clicked!)

 

Thanks

 

 

Roland Smith Accepted Answer Pending Moderation
  1. Thursday, 2 May 2024 17:41 PM UTC
  2. PowerBuilder
  3. # 1
Comment
There are no comments made yet.
Louis Arena Accepted Answer Pending Moderation
  1. Friday, 3 May 2024 16:49 PM UTC
  2. PowerBuilder
  3. # 2

Roland, thanks for the link but this does not really address my needs.  In the example, they already defined what script would be run, which is just a message box.  I already in my app am able to make visible what "dymanic" menu I want to display and change the menu name.  What I am missing is being able to dynamically set the script within that menu.  

As stated above I have gm_menu_favs[1] = m_mdi_frame.m_report.m_all_sales

 

What I want the menu script in the clicked event to be is

gm_menu_fav[1].triggerevent(Clicked!)

 

but I am not allowed to.  So does anyone have an idea how to dynamically change the clicked event in a menu?

Comment
  1. Subrat patra
  2. Saturday, 17 August 2024 02:21 AM UTC
HI @Louis Aerna - Can you please suggest how did you able to add the submenu items to a particular menu item dynamically ? I also have same type of requirement.It will be very helpful if you suggest the approach.
  1. Helpful
  1. Suguna Thamaraiselvan
  2. Thursday, 10 October 2024 05:14 AM UTC
Hi @Rene,



In the above comment, you have mentioned as below.

What you can do: Use the Item property of a menu to get its child items. So you can find a item by its classname.



e.g.



FOR ll_menu = 1 TO UpperBound (lm_current.Item)



IF lm_current.Item [ll_menu].Classname() = "m_fav1" THEN



...



END IF



NEXT



May I know, where this code should be written?



Thanks.
  1. Helpful
  1. René Ullrich
  2. Thursday, 10 October 2024 05:33 AM UTC
Hi Suguna,

You can write it in a script where you want to call menu items code (as in the original question).
  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.