[Gambas-user] IDE renaming
Bruce
adamnt42 at gmail.com
Thu Oct 8 16:19:17 CEST 2020
On 8/10/20 6:57 pm, Dag Jarle Nerland Johansen - Gambas wrote:
> Hi,
> I found a little thing in the IDE which may cause irritation by testing
> a program.
> If an object is renamed on the form, it works very fine, the source is
> changed too, a great benefit indeed.
> But if a menu item is renamed, it is not changed in the source.
> Not a big deal, in my programs I only link the menu-click to a
> button-click, but sometime I use time to find the "error", which is
> none. That is when I make more changes, get distracted from something
> else, start and the click on the menu doesn't work.
> In fact only a beauty thing, but perhaps someone has time to change that.
> Regards,
> Dag
>
>
> ----[ http://gambaswiki.org/wiki/doc/netiquette ]----
Dag,
I confirm your observation and profer the followin (manual) test script
to show how it v=can be dangerous and why RETRO-fitting Actions doesn't
solve the problem (for anyone that cares).
bruce
Test script 1: A simple view
1. Create a new project
2. In the FMain form designer, click Menu Editor
3. Add a top level menu named "mnuProgram"captioned "Program"
4. Add a submenu item named "MnuNewXYZ" caption "New..."
5. Open the form class file (just to check that it is clear)
6. Go back to the form designer and open the menu editor
7. Double click on the "New" item in the tree
8. Go back to the code - there should be a new method "mnuNewXYZ_Click()"
9. Go back to the form designer and open the menu editor
10. Click on "New" in the tree
11. Change the Name to mnuNewABC
12. Double click on "New" in the tree
13. Click SAVE to go back to the code editor
14. OBSERVE! The IDE has not changed the anme of the menu hanlder.
Instead it has created a new one with the new name
Test script 2: To satisfy some why this is dangerous
1. Add some code to each menu handler, say
Print "Row, row your boat\nGently down the stream"
and
Print "Motivate your speedboat up that reknown creek"
2. Now imagine that it is 5 years later and the code is now 1200 lines
long and both these methods are randomly somewhere
3. Go back to the form designer & Menu Editor
4. Change the name of the "New" item to "mnuNewXYZZY"
5. SAve the menu then double click on "New" in the form designer
6. Observe, Yet another menu handler. OK but lets make it
Print "Yet another menu handler"
7. Imagine waiting a year.
8. Go back to the form designer / Menu Editor change the name of the
"New" menu back to "mnuNewXYZ" and Add "PLUGH" to the "New" menu as an
action string
9. Save the menu and doubl click on "New" in the menu in the form designer
10. Add an Action_Activate menthd as follows:
Public Sub Action_Activate(sKey As String) As Boolean
If skey = "PLUGH" Then Print "What a waste of time..."; sKey
End
11. Run the program and select "New" in the menu
12. OBSERVE! Both the new avtion and the old handler are executed!
(Pity you if the old one did something dangerous like initialisng
your database or something!)
So expecting that retro-fitting ab Action handler does not solve the
observed problem which is "Changeing the name of a menu item does not
chane the name of the handler in the code."
You still have to recognize that
Menus Do Not Work The Same Way As Controls.
More information about the User
mailing list