Hi guys,
This is my first post, also is the first time I program this type of HMI. I'm trying to read from usb port a barcode from a barcode reader and put it in a analogNumeric control.
So far no problem.
I'm trying the following: I want when the screen opens, the keyboard focus automatically will put into the analogNumeric , and I can't do it, I must click over the analognumeric for the keyboard focus can be put over the control and therefore read the barcode.
Is there a script to do that? Because I've looked everywhere and I was unable to find it.
Sorry for my poor english....
Thank you very much for your help.
best Regards
Put the focus in a AnalogNumeric
-
- Posts: 22
- Joined: Fri May 25, 2012 7:44 am
- Location: Charlotte, NC. USA
Re: Put the focus in a AnalogNumeric
Something like the below code can be placed in the screen's Opened event.
Assuming your AnalogNumeric Object is...
AnalogNumeric1
you can cast the object to its base class of
(Neo.ApplicationFramework.Controls.Controls.TextBox)
This exposes the "Focus" method on the underlying object. I have tested this in a simulated run of the project and it automatically focuses the analog numeric and shows the OnScreenKeyboard.
Code: Select all
((Neo.ApplicationFramework.Controls.Controls.TextBox)AnalogNumeric1.AdaptedObject).Focus();
AnalogNumeric1
you can cast the object to its base class of
(Neo.ApplicationFramework.Controls.Controls.TextBox)
This exposes the "Focus" method on the underlying object. I have tested this in a simulated run of the project and it automatically focuses the analog numeric and shows the OnScreenKeyboard.
Best Regards,
Patrick Hall
Patrick Hall
Re: Put the focus in a AnalogNumeric
your code works perfect...
Thank you very much... you save my life....
best regards,
Thank you very much... you save my life....
best regards,
Re: Put the focus in a AnalogNumeric
Hi,
I tested as per the previous post by Patrick. I was able to build with no error but still have an exception thrown error when I tried to simulate. Am I doing something wrong? Here is my script.
void Screen1_Opened(System.Object sender, System.EventArgs e)
{
((Neo.ApplicationFramework.Controls.Controls.TextBox) AnalogNumeric1.AdaptedObject).Focus();
}
Thanks and regards,
I tested as per the previous post by Patrick. I was able to build with no error but still have an exception thrown error when I tried to simulate. Am I doing something wrong? Here is my script.
void Screen1_Opened(System.Object sender, System.EventArgs e)
{
((Neo.ApplicationFramework.Controls.Controls.TextBox) AnalogNumeric1.AdaptedObject).Focus();
}
Thanks and regards,
-
- Posts: 824
- Joined: Tue Mar 13, 2012 9:53 am
Re: Put the focus in a AnalogNumeric
Please post the exception.
Best Regards,
Mark Monroe
Beijer Electronics, Inc. | Applications Engineer
Mark Monroe
Beijer Electronics, Inc. | Applications Engineer
Re: Put the focus in a AnalogNumeric
Hi Mark,
I found the issue. when I created a new project, I selected pc 800x600 as my target and add analognumeric object inside the screen. Then I added the script for screen open event. When I simulated the project, it gave me an exception. I changed to T7A as my target and now its working.
Thanks,
I found the issue. when I created a new project, I selected pc 800x600 as my target and add analognumeric object inside the screen. Then I added the script for screen open event. When I simulated the project, it gave me an exception. I changed to T7A as my target and now its working.
Thanks,
Re: Put the focus in a AnalogNumeric
Hello
Using the suggested script, I can select the analog numeric. But I need after entering a value (in a usb keyboard) the object comes back to focus again.
Do you have any suggestions?
I tried to use the Lost Focus, but the terminal restarts after entering the value in first.
void Screen1_Opened(System.Object sender, System.EventArgs e)
{
((Neo.ApplicationFramework.Controls.Controls.TextBox)AnalogNumeric1.AdaptedObject).Focus();
}
void AnalogNumeric1_LostFocus(System.Object sender, System.EventArgs e)
{
((Neo.ApplicationFramework.Controls.Controls.TextBox)AnalogNumeric1.AdaptedObject).Focus();
}
Grateful for the attention.
Using the suggested script, I can select the analog numeric. But I need after entering a value (in a usb keyboard) the object comes back to focus again.
Do you have any suggestions?
I tried to use the Lost Focus, but the terminal restarts after entering the value in first.
void Screen1_Opened(System.Object sender, System.EventArgs e)
{
((Neo.ApplicationFramework.Controls.Controls.TextBox)AnalogNumeric1.AdaptedObject).Focus();
}
void AnalogNumeric1_LostFocus(System.Object sender, System.EventArgs e)
{
((Neo.ApplicationFramework.Controls.Controls.TextBox)AnalogNumeric1.AdaptedObject).Focus();
}
Grateful for the attention.
Re: Put the focus in a AnalogNumeric
douglas wrote:Hello
Using the suggested script, I can select the analog numeric. But I need after entering a value (in a usb keyboard) the object comes back to focus again.
Do you have any suggestions?
I tried to use the Lost Focus, but the terminal restarts after entering the value in first.
void Screen1_Opened(System.Object sender, System.EventArgs e)
{
((Neo.ApplicationFramework.Controls.Controls.TextBox)AnalogNumeric1.AdaptedObject).Focus();
}
void AnalogNumeric1_LostFocus(System.Object sender, System.EventArgs e)
{
((Neo.ApplicationFramework.Controls.Controls.TextBox)AnalogNumeric1.AdaptedObject).Focus();
}
Grateful for the attention.
((Neo.ApplicationFramework.Controls.AnalogNumericFX)AnalogNumeric1.AdaptedObject).Focus();