Form Menu Code Expert

Discussions related to Visual Prolog
User avatar
Richard Clarke
Posts: 23
Joined: 15 Mar 2012 15:55

Form Menu Code Expert

Unread post by Richard Clarke » 10 Apr 2012 16:38

Is there a code expert (such as that available for the Task Window) to generate the necessary code in the form implemenation file of a form (that has an associated menu) in response to menu item selections?
If not, is there a workaround to write the code manually?
Ditto if the form has an associated toolbar?
I am using 7.3 PE.

I have tried (in <myfrom>.pro)

Code: Select all

predicates     onMenuItem : window::menuItemListener. clauses     onMenuItem(_Source, MenuTAG):-         write(className, "Event: onMenuItem"," MenuTAG  ",MenuTAG,"\n").


which shows in MESSAGES theMenuTAG (number) generated for a given key press, but that is of little use without an association between the MenuTAG and the menu item e.g. id_file_new_point.
RSC

Steve Lympany
VIP Member
Posts: 119
Joined: 31 Mar 2001 23:01

Unread post by Steve Lympany » 11 Apr 2012 17:20

Hi,
You are almost there. If you have menu items "fred" and "joe" in the associated menu:

Code: Select all

predicates     onMenuItem : window::menuItemListener. clauses     onMenuItem(_Source, resourceIdentifiers::id_fred):-!,do_fred().     onMenuItem(_Source, resourceIdentifiers::id_joe):-!,do_joe().     onMenuItem(_Source, _).%catchall - no such menu item
cheers
s

User avatar
Richard Clarke
Posts: 23
Joined: 15 Mar 2012 15:55

Unread post by Richard Clarke » 12 Apr 2012 0:09

Yes I figured. But it would be easier with the code expert.
You could bring up the code expert via right click on a form or a dilaog in v 6.3; I wonder why its no longer available. :shock:
RSC

User avatar
Tonton Luc
VIP Member
Posts: 501
Joined: 16 Oct 2001 23:01

Unread post by Tonton Luc » 12 Apr 2012 6:42

Hi Richard,

You can use Code Expert via menu View (or CTRL+Shift+W).
:wink:

User avatar
Thomas Linder Puls
VIP Member
Posts: 1624
Joined: 28 Feb 2000 0:01

Unread post by Thomas Linder Puls » 12 Apr 2012 8:12

The code expert is not used for dialogs, forms and controls. You use the property editor instead, which have an Events tab, where you attach event handlers (see picture; notice that it says Form: myForm).
Attachments
FormEvents.png
Form Events (menu listener)
FormEvents.png (13.37 KiB) Viewed 6665 times
Regards Thomas Linder Puls
PDC

User avatar
Richard Clarke
Posts: 23
Joined: 15 Mar 2012 15:55

Unread post by Richard Clarke » 12 Apr 2012 13:42

The Dialog and Windows expert is not available for forms (or dialogs) via menu View (or CTRL+Shift+W). - a note pops up saying <form name>|<dialog name> is not associated with a dialog or window

The property editor does not provide for code generation for menu items (as it does for windows). The functionality and purpose of the property editor are different from that of the Dialog and Windows expert

In version 6.3 user could launch Dialog and Windows expert for forms and dialogs via (a) right click on form (or dialog) in project tree, select code expert or (b) right click on form (or dialog) in project tree, select attributes, then click code expert button in dialog that appears or (c) select form (or dialog) in project tree then select Menu/View/Code Expert (or CTRL+Shift+W).

In version 7.3 NONE of these ways of launching the Dialog and Windows expert are implemented for forms and dialogs, and I have found no other way to launch it. You can, however, launch Dialog and Windows expert for the task window by (b) right click on window in project tree, select attributes, then click code expert button in dialog that appears or (c) select form (or dialog) in project tree then select Menu/View/Code Expert (or CTRL+Shift+W).
RSC

Steve Lympany
VIP Member
Posts: 119
Joined: 31 Mar 2001 23:01

Unread post by Steve Lympany » 12 Apr 2012 14:13

Hi,
Yes, you're right. Right clicking shows a popup menu for forms+dialogs with "code expert" greyed out.

I'd not really noticed. I'd managed to work without it without problems.

cheers
s

User avatar
Thomas Linder Puls
VIP Member
Posts: 1624
Joined: 28 Feb 2000 0:01

Re:

Unread post by Thomas Linder Puls » 12 Apr 2012 16:24

Richard Clarke wrote:The property editor does not provide for code generation for menu items (as it does for windows). The functionality and purpose of the property editor are different from that of the Dialog and Windows expert
Thje property editor is all that is there. It will attach a menu item handler, but you will yourself have to add clauses for each of the menu items you wish to handle.
Regards Thomas Linder Puls
PDC

User avatar
Richard Clarke
Posts: 23
Joined: 15 Mar 2012 15:55

Unread post by Richard Clarke » 12 Apr 2012 23:37

I know the property editor is all that is there: that is exactly whay have pointed out. :-( The question remains why is the Dialogs and Windows Expert no longer available for forms and dialogs? It was available in version 6.3 for windows forms and dialogs, and worked just fine. Under 7.3 it is only available for windows. Since windows can no longer be created in 7.3 it is effectively restricted to the task window. Is its omission in 7.3 intentional or a bug? If the former what was the reason? How is the product improved? If the latter should I report it as a bug? :?:
RSC

User avatar
Thomas Linder Puls
VIP Member
Posts: 1624
Joined: 28 Feb 2000 0:01

Unread post by Thomas Linder Puls » 13 Apr 2012 8:29

It is intensional and it is also the intension that it will dissappear from the task window when we get to it.

It is also the intension to reintroduce a way to deal with individual menu items again, but it has unfortunately drifted out of our focus.

The reason is to remove some complexity in the IDE. The system used to have a lot of different editors/dialogs for various things
  • In the layout editor you add controls to dialogs/forms and handle the layout (most attributes of controls used to be handled in separate dialogs)
  • The attributes of the dialog/form/window was on a separate dialog
  • The menu handling and some other even handling was on the Dialog and Window expert
The intension is that all these things should be handled in a single "view", consisting of the layout area and the Properties editor (and the Controls and Layout toolbars).

I guess, we should add one more tab on the Properties editor for dealing with the individual menu entities.
Regards Thomas Linder Puls
PDC

User avatar
Richard Clarke
Posts: 23
Joined: 15 Mar 2012 15:55

Unread post by Richard Clarke » 14 Apr 2012 16:12

Sounds worthy. If you look at the help on creating a form, at Creating a Form you will see that the illustration shows what you now get, i.e the Form Properties Dialog but the description below matches not that but the Window Attributes Dialog (which is what you used to get under 6.3 but now only get for a .win file, i.e. effectively the Task Window., via right-click Task.win select attributes.)

:? Confused? Confusing! :!:
As others have mentioned you don't NEED the code expert: you can hand write code like
..
onMenuItem(Source,id_file_close):-
WH= Source:getVPIWindow(), vpi::winDestroy(WH),!.
onMenuItem(Source, id_style_font):-
WindowHandle= Source:getVPIWindow(),
OldFont=vpi::winGetFont(WindowHandle),
_RetFont= vpiCommonDialogs::getFont(OldFont, NewFontName, NewFontSize),
write("", className," NewFontName: ", NewFontName," NewFontSize: ",NewFontSize,"\n"),!.
..
which is more compact than the code expert would generate e.g.
predicates
onHelpAbout : window::menuItemListener.
clauses
onHelpAbout(TaskWin, _MenuTag):-
_AboutDialog = aboutDialog::display(TaskWin).

predicates
onFileExit : window::menuItemListener.
clauses
onFileExit(_, _MenuTag):-
close().
but the code expert launched via the Window Attributes Dialog was convenient, and the Window Attributes Dialog gathered it all together, i,e properties and code expert/menu options. I liked it! :-)

Best wishes
RSC

User avatar
Richard Clarke
Posts: 23
Joined: 15 Mar 2012 15:55

Unread post by Richard Clarke » 21 Apr 2012 23:52

The help file says re Dialog and Window Expert

Dialog and Window ExpertThe Dialog and Window Expert is a tool that connects Visual Prolog code to layouts of windows, dialogs, forms, and IDE controls. After a dialog or a window is designed, the Dialog and Window Expert can be used to generate the necessary Visual Prolog code to manage window and dialog creation and event handling.
[emphasis added]

This is inaccurate since it is no longer available for dialogs and forms,. I have not checked IDE controls.
RSC

User avatar
Richard Clarke
Posts: 23
Joined: 15 Mar 2012 15:55

Form Menu Code Expert

Unread post by Richard Clarke » 11 Feb 2016 1:17

A while ago it was said "I guess, we should add one more tab on the Properties editor for dealing with the individual menu entities."

I can see under Properties, Menu: you get to choose the menu you have created
but this is not exactly "dealing with the individual menu entities"

I'd like to be able to add a menu to a form without too much effort. (i.e with help of code expert) It's easy enough dealing with the task menu; why make it more difficult for other menus?

What is state of play?
RSC

User avatar
Thomas Linder Puls
VIP Member
Posts: 1624
Joined: 28 Feb 2000 0:01

Unread post by Thomas Linder Puls » 11 Feb 2016 9:14

I am afraid that this issue has not been addresses.
Regards Thomas Linder Puls
PDC

User avatar
Richard Clarke
Posts: 23
Joined: 15 Mar 2012 15:55

Unread post by Richard Clarke » 12 Feb 2016 21:49

It's the lack of symmetry, if that's the right word, that is disconcerting.

There is admirable assistance from the code expert when using the taskmenu, but not for other menus of user creation. This is not logical., or should I say not orthogonal.. Both are menus so user would expect their behaviour and treatment to be the same...In fact they WERE treated the same in previous versions but for some reason, it was decided to change that. Hooray (not!).
RSC

Post Reply