Page 1 of 1

What is TaskMenu item?

Posted: 16 Jul 2015 7:11
by Peter Muraya
Hi,
When you open TaskMenu.mnu to access the task menu editor you see the following inputs for each menu item: Constant, Item and Help. I understand Constant to be the text that defines a constant in the resourceIdenfiers and has the vpiDomains::menuTag; but what is item? Why is it important? What is its domain? How can I access it programmatically?

Menu items

Posted: 20 Aug 2015 7:36
by Ferenc Nagy
Peter,
Open the TaskMenu.mnu file.
There you can modify the Task menu.
Open the TaskWindow.win file,
There you can add menu handling predicates.

They look like this where clicking on a menu item
1) does a special action and
2) enables/disables other menu items.

Code: Select all

predicates     onLogSuspend : window::menuItemListener. clauses      onLogSuspend(_Source, _MenuTag) :-         output_file_statistics:its_state=fileStatistics::active,         !,         output_file_statistics:its_state:=fileStatistics::suspended,         Task=getVpiWindow(),         vpi::menuEnable(Task,resourceIdentifiers::id_log_create,b_false),         vpi::menuEnable(Task,resourceIdentifiers::id_log_resume,b_true),         vpi::menuEnable(Task,resourceIdentifiers::id_log_suspend,b_false),         vpi::menuEnable(Task,resourceIdentifiers::id_log_close,b_true).     onLogSuspend(_Source, _MenuTag).
I hope this helps.

Posted: 20 Aug 2015 17:31
by Peter Muraya
Hi Frank,
Ok, so Item does what I thought Constant does. Then I should switch my question the other way round so that it reads:-

When you open TaskMenu.mnu to access the task menu editor you see the following inputs for each menu item: Constant, Item and Help. I understand Item to be the text that defines a constant in the resourceIdenfiers and has the vpiDomains::menuTag; but what is Constant?

I have seen that the Constant value is always the same as the Item value. In this example I have deliberately entered the two to be different. What purpose does the constant serve?

Posted: 20 Aug 2015 18:41
by Thomas Linder Puls
I think the "constant" has lost it meaning/purpose at some point.

I think it used to be used as prefix for sub-menu items.

Re: Menu items

Posted: 20 Aug 2015 21:29
by Harrison Pratt
Question for Thomas:

Might it be possible in some future version of VIP 7.x to combine the functions of managing TaskMenu.mnu and TaskMenu.win using two different "experts" into a single "super-expert?"

To me, the current approach seems more awkward than it needs to be.

Posted: 21 Aug 2015 6:29
by Peter Muraya
Hello Harrison,
I agree with you. It was not intuitive when I first used the code experts that the use of the .win was to extend the functionality of the .mnu file.

Thomas wrote
I think the "constant" has lost it meaning/purpose at some point.
When I initially found Constant and Item in the Task Menu this is how I thought they would be used:-
1) Constant is where you place the string version of the id that is found in resourceIdentifiers and is added to the menu listener
2) Item is a place where you could enter some user specified data that the one would wish to associate with the menu item. The data would be any valid prolog expression as a string that would have to converted to the appropriate domain to be useful.

If such were case, then the following entry would be valid:-
Constant: id_open_file
Item: "C:\some_directory\somefile.txt"

... where the Item domain is filename (string) to be opened when you select the Open menu.

Item and constant

Posted: 26 Aug 2015 17:19
by Ferenc Nagy
Peter,
If you generate a deep menu structure the the sub-items inherit the constant of their parent menu branch and a simplified text of the item is added to it in order to form the equal constant and item resource identifiers.

This rule of formation results a logical naming mirroring the structure of menu tree of sub-sub-sub-menuitems but the resource identifiers may be very_very_loooooooooooooooooong.

You can however edit both fields to get shorter resource identifiers but you won't see their position on the menu tree.
The code generation for TaskWindow.win uses the string of "item".

Code: Select all

predicates     onFileExit : window::menuItemListener. clauses     onFileExit(_, _MenuTag) :-         close().   predicates     onDepth3item : window::menuItemListener. clauses     onDepth3item(_Source, _MenuTag).