Lose events for extjs form - forms

I have a big form on extjs which opens in window, and, for speed reasons, i cache it in hidden panel. There is can be only one window at time, so the cached form is single too. On show event i add form to window, with no rendering and with suspendLayout option for form. On close event i move the form to hidden panel, with panels add method. I do not use remove method not for window not for panel. So, for several times all perfect, but after 3- 5 window openings form lose all of its events: buttons, comboboxes, triggers and other controls are not responding. Where is the problem? Thank you.

It is difficult to know for certain but my theory is that the observable object that your listeners are setup on is garbage collected at some indeterminate time period of inactivity.
I have seen this occur on an object representing the body of an iframe that is watched from the parent window. Click events from the body will work for some time and then all events will stop.
One way to test the theory is to store object reference in a global variable - this is NOT what you want to do in any app but worth a try just to test. Global vars are never garbage collected.

Related

Wicket AjaxTabbedPanel with tab content panels that defer rendering until tab is activated

I have a page with an AjaxTabbedPanel with lots of tabs with content like charts, reports, etc., whose content is quite expensive to produce. Most users spend most of their time on the first panel and don't need to venture to the tabs with charts, reports etc.,
To avoid unnecessary work on the back end and provide a faster initial page render I thought it would be advantageous to avoid doing the work to populate a tab's contents until (and only if) the user clicks on a tab to activate and thus render that tab's content.
Of course the first tab will always load during initial page load as that is the one that is active by default but the other tabs' contents will lay dormant until the user clicks on the corresponding tab, avoiding doing any work for those dormant panels until necessary.
Is that possible?
I thought that I could possibly employ the AjaxLazyLoadedPanel but it seems to be designed for a different purpose and the lazy loaded panel is regularly polled until it is 'ready' but that's not what I need in my case: there's no need for polling, we will know when to render a panel's content i.e. when activation of the panel occurs.
TabbedPanel does not need a tab's content as long at is isn't shown.
Make sure that you implement ITab#getPanel() 'lazy', i.e. the panel is created only when that method is called the first time. See PanelCachingTab for inspiration.

Delphi How can I detect a click event anywhere on a form including other components

I have a TEdit in a Delphi VCL form app (contained in a TFrame instance, if it matters). After a user indicates they are finished editing, by clicking elsewhere on the form, the caret and focus remain on this control until I click on another control, which then takes the focus. However, I want the TEdit to loose focus regardless of where the user clicks. I expect I can use ActiveControl := nil to end focus on the selected control, but I am uncertain where to invoke it.
What I want is for the focus to leave the selected control without necessarily having to transfer it to another control. I could end focus in the form's OnClick event, but that will not work if the user selects any of the other controls (also contained in frames) on my form, since the form's OnClick event is not triggered. It seems inelegant and tedious to provide separate OnClick events for each additional item on the form.
What is the global solution to achieve this behavior?
Try using the TApplication(Events).OnMessage event to look for WM_LBUTTONDOWN messages.
You can use the VCL's FindVCLWindow() or FindDragTarget() function (both in the Vcl.Controls unit) to see if there is a TWinControl located at the click coordinates. Or simpler, you can use the VCL's FindControl() function (also in the Vcl.Controls unit) to get an TWinControl directly from the message's target HWND.
If no control exists under the mouse, or if the control is not focusable (its CanFocus() method returns False), then set ActiveControl=nil. Otherwise, do nothing, and let the clicked control take focus on its own when the message is processed.

How can I persist state in a VS Code WebviewPanel after it is destroyed?

After looking at the documentation, I'm able to persist state in the following two cases:
When a WebviewPanel is hidden (ie, the user switches tabs) using getState/setState
When the user restarts the VS Code by implementing a WebviewPanelSerializer
However, I don't see a way to persist state when the panel is destroyed (ie, the user closes it or calls dispose). Here's my scenario:
I execute a command to show the WebviewPanel
I have an input box in the HTML content. I type some string in and press a button to save it. Upon saving, I save it using setState and then append a div with the entered text into the webview.
I close the panel and execute the command again. The panel does not have the appended div.
You have 2 options:
Recreate the additional div when you find saved state (e.g. the input from the user).
Use retainContextWhenHidden to keep the content of the webview, even if it is moved to the background.
The latter won't help when the user closed the webview, however, and is much more resource hungry than the state save/restore operation.

forms showing in runtime as soon as they are created

In runtime when the forms are being created, 2 forms constantly keep appearing when I haven't programmed them to show as soon as they are created, and my system runs. I was wondering why this happened and whether there is anything to solve this? I don't think I need to show my code here since it's pretty basic and there is none for the OnCreate event.
From the main menu, use Project->Options->Forms, and remove the forms you don't want to see from the Auto-create list. (Click the >> button to move them from the left side to the right side.)
(It's worth mentioning that you can also affect the order in which any autocreated forms or datamodules are created from that dialog by just dragging them up or down in the list. Note that the first form to be created becomes the application main form, so when it is closed the application will close as well; this means that the only thing above your main form in the autocreate list should be datamodule(s) that are accessed by the main form.)
If you never want any forms auto-created, go to Tools->Options->Environment Options->Form Designer, and uncheck the very last item labeled Auto create forms & data modules at the bottom. Note that your main form will always be auto-created, as it's what controls the application's lifetime for form based applications.
By default delphi creates all the forms in the beginning. You can open the .dpr file and delete the ones that you don't need. You could also do that from the UI.
For the forms that you don't want to appear at the start of runtime, go to the properties of the form (lower left hand side) and uncheck Visible. This should do the trick

Presenter saves the textbox value in gwtp, gwt

I tried to develop a shopping cart application.
I am able to process the deal. but when the user click the fresh start after completing the deal the first page starts with the value which I have entered previously.
I am using gwtp, uibinders, I have back, cancel, next functionality in series of screens.
what to do to make sure the screen is blank for every new start of deal.
I don't know which design pattern you use, but usually a "view" keeps its state after it is hidden. When you show your view the second time, you have to reset the values of all fields (textboxes, inputs, etc.), or they will show their state from the previous time.