In my application I call App.Current.MainWindow.Show()/App.Current.MainWindow.Hide() to show/hide my application but I don't know how to catch the event when the form is hidden/showed. Please help if you know how to!
One of your tags is WPF and the other is WinForms... I'm better with WinForms, so I'll answer for that tag.
The Form.Shown event documentation is here with sample code...
There is no corresponding Form.Hidden event. The best you can do is choose from Form.Closing or Form.Closed or one of the other events.
Added from my comment above
Question - if you're CALLING the Hide and Show in your code, why do you need to capture the events? You already KNOW when it's happening. If you want to run some code inside the form after hiding and closing it, expose the code as a public function, and call the function after showing and hiding the form...
Related
In a test-class, is there any way to invoke Buttons inside the toolbar, without a name (""), which were added like this?
getToolbar().addMaterialCommandToRightBar("", FontImage.MATERIAL_PICTURE_AS_PDF, e -> createPDF());
Or can I somehow tell the test-class to show a specific form ?(which is happening when I click the button without a label).
The test recorder is not generating any code in that case. It seems that it is only working with buttons, which have a non-empty String as name, as they are simply invoked by
clickButtonByLabel("Label");
The test recorder was written before the Toolbar existed, we tried to update it for the Toolbar recently but this proved to be pretty difficult.
We have this issue that covers this bug. As a workaround you can post the command directly in the code of the test.
I wanted to have a Dialog box for asking to save the current changes or not. For that I was searching for an event in AngularJS which triggers on change of any scope variable.
As per my logic I will achieve this by creating event on every control and update a variable to say 'Modified' else will have default value.
Is there any other way? Since my logic will need an event on every control.
If you're using a form directive, this is pretty simple. The value of myForm.$dirty will be true if any property has changed. You can even check an individual field with myForm.myField.$dirty.
If you're not using a form, you should probably consider it for what it sounds like you're trying to accomplish. One of my favorite angular features as it makes validation, etc. a breeze!
Reference: angular docs
Take a look at $scope.$watch(...) on the Angular docs, there is a great discussion on how $watch works here on another Stack Overflow question
You should, at the very least, be able to trigger alerts when specific scope-elements have changed. If you are using a form, then the $dirty approach above is absolutely a brilliant way to go.
I have a form designed with the GUI designer with input textfields and buttons. I have attached actions to the buttons. When I call up the form with showForm(Form,null), the textfields are not accepting input and the buttons are not triggering the action. This is happening only for this form. Initially, there was the problem solved here Unable to call a specific form from a button in codenameone and then the problem solved here Simulator keeps defaulting to old Main form. What could be the issue now?
As far as I know there may be some issues as you say, but first need to see code
In the form after you added the text fields did you select the text field component and press action event?
Assuming you did that you should get a callback method in the Statemachine class.
This call will be invoked only when the user changes the content of the text field. You can run in the debugger and set breakpoints/step into code to see what is going on.
ExtJS 4.1.
Is there something like Ext.button.click(); method on Ext.button class?
Is it possible to programmically "click" a button with one method?
Or if you have an MVC structure you can fire the click event of the button, and if you're listening to the event in your controller and have an associated function it will get called.
button.fireEvent('click', button);
The last answer on this forum might give you more insight on how you can do that
here they are-
1)Create the event code in a function and call the function from both sides: btn.on("clic", ...) and from the code you want to simulate the click.
2)Use: btnView.btnEl.dom.click();
from -
http://www.sencha.com/forum/showthread.php?37772-Solved-Programmatically-click-an-Ext.Button
ExtJS 4.2.1
Ext.get('component-id-of-extjs-button').el.dom.click();
Ext.get('toggle-button2').el.dom.click();
works for me.
In case of buttons using handler, you can directly call the function of button.
Considering button is an Ext JS component, you can use:
button.handler(button);
or if you want to reach a function of event 'click':
button.listeners.click(button);
That would also work to call different button events.
Since I needed it for many buttons, it was easier to implement an override on the button class, which adds a click function:
Ext.define('Ext.override.Button',{
override:'Ext.button.Button',
click:function() {
this.getEl().dom.click();
}
})
After this override has been added to the code base, the following works like a charm:
Ext.getCmp("MyButton").click()
Unlike fireEvent or fireHandler, this will work with all kinds of buttons - no matter whether they have a click event or a handler, or whether they are toggle buttons where the clicked button has to be marked as pressed also.
If you need to execute the "handler" of the button, just run this (tested with ExtJS 4.2)
button.fireHandler()
If you want to do this in your test scripts, take a look at my Ext.ux.Test library. If you need it for something other, I would suggest reconsidering your approach.
None of the other answers worked for me, but i found something simplier i think :
var button=Ext.get('the_id_div');
button.dom.click();
document.getElementById("someButtonId").click();
I'm using this code to grab barcodes from the camera:
http://blogs.msdn.com/b/stephe/archive/2011/11/07/wp7-real-time-video-scan-a-barcode-qr-code-in-your-app-using-zxing-lib.aspx
It works fine if it is called from a button press, but if you put it in page load nothing happens, I assume this is a security feature?
Is there any way around it?
Thanks
All must be Ok with Loaded event. Maybe you put code inside constructor instead...