WP7 - Is it possible to automatically launch the camera capture without a button press? - silverlight

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...

Related

Is this a bug? Using a touch input (With mouse input on) on a button but nothing is done

I am using a button to transit to another layer. But I can't transit to that layer. I am using construct 3.
When I click on that button
onTouched an object (the object is that button) -> Go to layer (Layer02)
But nothing happens. I am using Touch but I have set the mouse input on. I used other object to try such as text field, and it works. Everything works except when I used button.
Is it a bug? Or I am not doing it right. The variables you see in the picture are for debugging purposes.
These are my events:
I think you refer to "transit to another layout" (not layer) 😉
On your screenshot I see all your events are OK. If you add Touch doesn't need add Mouse (you can use the mouse to simulate touch on browser).
I create a new project with the same events and works correctly, I attach a .c3p so you can try it. 😌
https://www.dropbox.com/s/7x1r27rs5a6k5d0/button_layout.c3p?dl=0

Share button disappearing from toolbar after the first click and how to add it as command

This is my code guys
ShareButton share = new ShareButton();
share.setIcon(icon);
share.setTextToShare("Text yada yada");
tb.add(BorderLayout.EAST, share);
Its just disappearing from the bar after a single click. I also wanna know how to invoke the share functionality on a command thats on the side menu
Thanks in advance
Apparently its a simulator problem. Works well on device
The way you add the button to the toolbar is illegal and incorrect. It will behave erratically across devices based on the different behaviors.
You should use a command such as addMaterialCommand on the toolbar and then invoke the share functionality in Display.

TestRecorder with MaterialCommand in Toolbar

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.

Ext.button click() method

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();

How to catch/handle the window form's hidden/showed events?

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...

Resources