I have some stuff in the OnShow event of a main form that fills a few listboxes with a procedure StuffLB. I need these listboxes refilled after any of my other forms have been shown with a call to ShowModal.
After such a modal form closes, the main form is just repainted there where the modal form was and its OnShow event does not fire.
The only way I can get the OnShow event to fire is by:
frmM.Hide;
frmB.ShowModal;
frmM.Show;
Is the only way I can get the listboxes filled to use the StuffLB call after every ShowModal call on sub forms? I have about 25 forms that are available.
I would had hoped that OnShow meant when it was shown again, either in part or in full.
I'd appreciate any help or suggestions.
OnShow event fires when form becomes visible. What you may use is OnActivate event. However, since it is your code that calls ShowModal of another form, just put required code in a separate method and call here and in FormShow.
Related
Hi I have main form in which I am displaying user controls like ManageDepartment. I have few buttons like RESET in main form.
I want to have event in ManageDepartment to reset controls.
When user clicks on Reset Button on main form, the button should call the reset event on displayed control i.e. ManageDepartment
Can any one suggest me how can I achieve this?
If this is duplicate question, please direct me to original question.
You don't call an event. If the user control has a Reset event then that event would get raised by that control.
It sounds more like what you need is a Reset method on the user control. You would handle the Click event of the Button on the form and call the Reset method of the control. In that method you would do as required to reset the control, e.g. call Clear on each TextBox.
I have a region, and I need to execute some code once the view is rendered. So the first time I call myRegion.show(myView)The code that goes inside onShow in myView does the work.
The same piece of code doesn't work onRender or at initialize. The problem comes, when after a change in myView I call this.render() to reflect the changes. This time, "onShow" is not firing.
I think that I can trigger an event from the view, catch it at the parent view and call again to myRegion.show(myView). But it looks like a tricky solution, and I don't know if there could be a better way to manage this situation.
onShow callback is called only once when you insert your view into the region.
I think in your case you should use onDomRefresh. Marionette calls it when view is showed into region and when it is re-rendered (but only when it is showed already). So you can make all your DOM dependent code in it.
You can read more in docs: https://github.com/marionettejs/backbone.marionette/blob/master/docs/marionette.view.md#view-domrefresh--ondomrefresh-event
I have a navigation view with one button in the toolbar. Based on the view pushed, the button's label and functionality should chang. I've managed to do this by creating many buttons and activating them as needed (hide/show)
Instead of doing that approach I'd like to have just one button and in the controller change the text and action. Something along these lines:
this.getButton().setHtml("new text");
this.getButton().action = "newaction";
setHtml works, but setting the action doesn't. Examining the button in the console, I see the action changes but when I click it, it responds to the previous action.
Any suggestions on how to approach this?
Thanks
You should use setText instead of setHtml that, err... Doesn't seem to exist! And setHandler to change the handler function.
Alternatively, since you say that you're working in a controller, you can attach a function to the click event of the button and, inside this listener function, decide what action to execute in the current context.
I am developing application using ExtJS 4.1. I have one spinner field and I want to change value of that method programatically. I have set up listeners like change, spinup and spindown for this same spinner field.
Now I would like to know how to prevent listener method of these events getting fired only when I change the value of spinner field through my program?
For example,
var mySpinner = Ext.ComponentQuery.query('#foopanel > #mySpinner')[0];
mySpinner.setValue(2000);
When mySpinner.setValue(2000); line is executed, change event of mySpinner gets fired and as I have listener method for this change event, that listener method is executed.
Is it possible to prevent invocation of change event listener method?
Thanks..
You could suspend all events by calling
mySpinner.suspendEvents();
mySpinner.setValue(2000);
mySpinner.resumeEvents();
That would be the cleanest an easiest way IMO
And that's also a usecase why this methods exist
I saw that it adds events to an Observable. However, you would only add it if you would fire it at some point. So, if you add the firing of the event at some line in your code, it was useless to put it into addEvents in the first place and when you don't place the fireEvent in your code then it was pointless to include it in addEvents. What am I missing?
If you are adding custom events with your component then you must add the events with addEvent before you can fire the events with fireEvent. Adding and firing events is useful in binding custom components together without explicitly referencing them.