I don’t get this to work. I have a button on a layout. In a Method I want to change the Enabled state to True, but keep on getting the message “This item does not exist”. Also, the button’s item name is not being predicted inside the Method, so apparently isn’t not being seen. What am I doing wrong?
The button is inside a container and that container is placed on a page panel. Maybe this has something to do with it?
All controls should be private to their window or container. Make a public method in the container for enabling/disabling. Now call the method which does the enabling/disabling. You have now mastered a simple form of information hiding. When you now have a second button, or a canvas based button instead you only have to change the code in the container and not the code that calls the container.
The button on the container is set to Public. So this means the same as having it global, right?
I just discovered that creating the method in the contain, makes the button visible.
I have 8 containers, so by keeping the controls Private their functionally stays with a container and cannot interfere with the other containers?
Thanks, I understand it much better now. Windows and Containers are separate islands, but can be reached from the outside by starting a method with their object name.
Doing this is not recommended. I’d go so far as to say this is a bad practice.
Any control, window, container should be treated as a black box where you do NOT reach down into its guts to make changes like this. The reason ? If you DO reach down into the guts then you have a much harder time changing the innards to a better / different implementation without also changing everything that does reach into it from outside.
If you create a method on the Container that is like
Sub ButtonEnabled(assigns isEnabled as boolean)
myButton.enabled = isEnabled
end sub
then that previous code turns into
myContainer ButtonEnabled = true
And, should you ever decide to rename the button or make some other change to your container you only change the code in the method already on the container (the API you exposed to the rest of your program) and NONE of the rest of your program has to change.
[quote=441979:@Emile Schwarz]Choose the ContainerControl (the original I suppose, unsure), and a MenuHandler.
In the right Pane, you will see a PopupMenu that allows you to choose the MenuItem,
the code can be added in the Code Editor (mid and large pane).[/quote]
That’s what I tried, but the MenuItem is not in PopupMenu to choose from, meaning that it is not reachable from here, right?
No, I didnt see this before. Must have missed it. I did create the example projects and of course after working with FileMaker for 3 years, wanted to continue at the same speed in Xojo. Thanks for the link, I will study this book first.
Yes, I added menu handlers all over the place by now. Nothing works. I better abandon my current project and starts from scratch. My lack of Xojo is what is giving me problems here.