Discussions related to Visual Prolog
Peter Muraya
VIP Member
Posts: 147
Joined: 5 Dec 2012 7:29

What is TaskMenu item?

Unread post 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?
Mutall Data Management Technical Support
User avatar
Ferenc Nagy
VIP Member
Posts: 215
Joined: 24 Apr 2007 12:26

Menu items

Unread post 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.
Attachments
Task Menu.mnu is being edited.
Task Menu.mnu is being edited.
Task Menu Item.PNG (20.23 KiB) Viewed 21204 times
Add menu handling events to the task window.
Add menu handling events to the task window.
TaskWindow.PNG (33.8 KiB) Viewed 21204 times
TIA, Regards,
Frank Nagy
Peter Muraya
VIP Member
Posts: 147
Joined: 5 Dec 2012 7:29

Unread post 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?
Attachments
Different values for Constant and Item
Different values for Constant and Item
item.png (12.13 KiB) Viewed 21191 times
Mutall Data Management Technical Support
User avatar
Thomas Linder Puls
VIP Member
Posts: 1398
Joined: 28 Feb 2000 0:01

Unread post 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.
Regards Thomas Linder Puls
PDC
Harrison Pratt
VIP Member
Posts: 439
Joined: 5 Nov 2000 0:01

Re: Menu items

Unread post 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.
Peter Muraya
VIP Member
Posts: 147
Joined: 5 Dec 2012 7:29

Unread post 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.
Mutall Data Management Technical Support
User avatar
Ferenc Nagy
VIP Member
Posts: 215
Joined: 24 Apr 2007 12:26

Item and constant

Unread post 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).
Attachments
Item differs from constant.
Item differs from constant.
item differs from constant.PNG (10.97 KiB) Viewed 21157 times
TIA, Regards,
Frank Nagy
Post Reply