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

 

 

Louis Arena Accepted Answer Pending Moderation
  1. Friday, 3 May 2024 16:49 PM UTC
  2. PowerBuilder
  3. # 1

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. Louis Arena
  2. Monday, 6 May 2024 12:37 PM UTC
If that is the case why did this not work?



gm_menu_fav[1].triggerevent(Clicked!)



The variable is the a string array.



I figured this out and will post how I did it for the next person but I would love to know why something like this is so difficult.
  1. Helpful
  1. René Ullrich
  2. Wednesday, 8 May 2024 13:13 PM UTC
You can trigger the event by its name: TriggerEvent("clicked")

But you can't have the menu item name in a string variable and use the menu item directly by its name.

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

  1. Helpful 2
  1. Louis Arena
  2. Wednesday, 8 May 2024 14:21 PM UTC
Rene, this is basically what I found and was able to get working. You however specified it in the simplest way possible. I hope others find what you posted useful. Thanks.
  1. Helpful
There are no comments made yet.
Roland Smith Accepted Answer Pending Moderation
  1. Thursday, 2 May 2024 17:41 PM UTC
  2. PowerBuilder
  3. # 2
Comment
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.