So I need to move one of my applications to Web 2.0.
The application’s basic navigation concept is that I have one page with multiple containers, created dynamically except for one, a treeview menu. The menu is inside a container called “wcMenu”. When an actionable menu item is selected, a bunch of things happen, notably inserting and showing of a new container on the page, followed with hiding and disabling “wcMenu”.
When the user is done with the business function, the user closes the container with a button. The code in the Pressed event includes the fillowing in 2019 R3.1:
The effect is to close the current container and reactivate the menu container.
Now, in 2020 R1.1, this code throws an error:
Type “WebView” has no member named “ControlWithName”
Self.Parent.ControlWithName(“wcMenu”).Enabled = True
It would seem that something changed in Web 2.0 that makes my code an incorrect approach.
Does anyone have any idea how I could achieve my desired behavior with Web 2.0? I spent some time in the documentation, and did not find anything. In fact, I would think based on the docs that this should still be valid. But obviously not…
In the container with the close button, you really should be raising an event (maybe “Closing”) that is handled in the parent and carries out the action.
In the button Pressed:
Sub Pressed() Handles Pressed
RaiseEvent Closing
self.Close
End Sub
Closing Definition:
Event Closing()
Handler for Closing on the parent:
Sub Closing() Handles Closing
wcMenu.Visible = True
wcMenu.Enabled = True
End Sub
That seems like a simple enough technique. I think that I understand clearly defining the event and raising the event.
Now, to handle an event, I only know to use the addhandler/removehandler keywords. That requires specifying the container (or dialog, etc.) So I would need one handler method for each of the containers that I am showing and closing. Is this what you are suggesting? if not, what am I missing here?
Do you have in mind something like this? I added the handler in the method that creates and embeds the containers
sub Opening (Item as GraffitiTreeItem)
....
Dim wcRespNew As New wcRespBaseNew
wcRespNew.EmbedWithin(Me, 0, 0, wcRespNew.Width, wcRespNew.Height)
wcRespNew.FC = Session.FCode
AddHandler wcRespNew.Closing, AddressOf ViewClosing
wcRespNew.visible = True
wcRespNew.enabled = True
...
end sub
and later
Sub ViewClosing(Sender as Webview)
wcMenu.Visible = True
wcMenu.Enabled = True
if Sender IsA wcRespBaseNew then
RemoveHandler wcRespNew.Closing, AddressOf ViewClosing
elseif Sender IsA wcManageAppTextsBase
RemoveHandler wcManageAppTexts.Closing, AddressOf ViewClosing
else
'etc.
end if
end sub
This code also throws an error. For example, wcRespNew is unknown. It was created and embedded by another method also present on the page. Up until now, I have only been successful removing a handler if I specify the actual object in the method parameters. I have not succeeded using generic types. Again, I must be missing something…
wcRespNew is a variable name that’s local to your Opening event handler. You’re trying to RemoveHandler from a variable that is not in scope. Maybe try this?
Your Self.Close is closing the page that has the menu on it. It would probably work fine if you just remove that line. I frequently toggle the Visible property of containers to show them as needed without ever closing anything until the session ends.
That code used to work just fine in web 1.0. Self.Close being part of a button event handler, did close just the currently viewed webcontainer (a configuration transaction, a customer master file transaction, etc.), leaving the page and the menu container intact. The issue is that I need to reproduce the behavior in 2.0, where ControlWithName no longer works in the way it did in web 1.0.
On the web page, I created a public method that hides the menu, and a public method that shows the menu. I just call the public methods from whereever appropriate. Why did I not think of this before?
The compiler seems to like it. I have a few hundreds of other errors to take care of before I can really test the solution.