Subject |
Re: Form2PopupMenu |
From |
Andy Taylor <andy.taylor.1959@outlook.com> |
Date |
Sat, 3 May 2025 15:04:05 +0100 |
Newsgroups |
dbase.getting-started |
Hi Tom,
I don't think you have taken the right moral there, even young &
brilliant coders fall into similar traps.
One method that I have found invaluable for this sort of thing is to
open up the inspector when designing a form and use the methods tab to
see where objects derive the code they actually run...
Regards,
Andy
On 03/05/2025 12:48, Tom wrote:
> On 4/25/25 12:32 PM, Tom wrote:
>> Given:
>>
>> set procedure to A2Demo.pop ADDITIVE // local folder ...
>> form.popupMenu = new A2DemoPopup(form,"A2POP") // menu belongs to form
>> *
>> What is the proper way to refer to refer to the popup menu item "List"
>> of the popup menu from the form to which it is attached so that I may
>> set it's enabled property to true or false? Tried lots of
>> combinations, none of which were successful yet. Fingers are tired of
>> typing so I will ask. :)
>> *
>> Tom
> *
> Now that we seem to be back on the air ...
> *
> I see (Sunday 1:30 pm local) that the dBase website is not working again
> so, I will have to wait to post this when it resumes.
> *
> There is nothing wrong with the following code. There should not be as I
> lifted it, verbatim, from David Stone's dBulletin issue 16 article.
> *
> set procedure to A2Demo.pop ADDITIVE // local folder ...
> form.popupMenu = new A2DemoPopup(form,"A2POP") // menu belongs to form
> *
> form.popupmenu.LIST.enabled = true // WORKS
> OR
> form.A2POP.LIST.enabled = true // WORKS
> *
> So, why didn't it work on my computer?
>
> The code for A2demoPop was originally written some time earlier for use
> on another form. I simply copied it for use on my 'oChild' type form. Of
> course, if it was an 'oChild' form, there would be an 'oParent type form
> around some where. In my testing, I kept opening the 'oChild' form and
> right clicked it to open the popup menu. Also I kept looking at the
> popup menu in the source editor when checking for errors. The code was
> rather lengthy and continued well below the source editor's display.
> Unfortunately, I did not pay attention to one particular line of code
> near the top that said 'onInitMenu = class::ROOT_ONINITMENU'. Here is
> that function from the popup menu.
> *
> Function ROOT_onInitMenu()
> * ------------------------------------ *
> this.CALENDAR.enabled = iif( this.parent.activeControl.baseClassName =
> "SPINBOX", true, false )
> this.LIST.enabled = iif( type("this.parent.activeControl.aList") = 'A',
> TRUE, False)
> return
> *
> Unfortunately, there is no activeControl initially on the oChild form
> that contains an aList and therefor the popup.list.enabled was always
> set (back) to false whenever the popup was initiated.
> *
> Moral of the story, being old and stupid is not good when trying to
> write dBase code.
> *
> My thanks to all who attempted to help. I shall try to do better in the
> future.
>
> Regards,
>
> Tom
|
|