Page 1 of 1

Put the focus in a AnalogNumeric

Posted: Tue Sep 25, 2012 3:32 am
by phrodo
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

Re: Put the focus in a AnalogNumeric

Posted: Tue Sep 25, 2012 10:32 am
by Patrick Hall
Something like the below code can be placed in the screen's Opened event.

Code: Select all

((Neo.ApplicationFramework.Controls.Controls.TextBox)AnalogNumeric1.AdaptedObject).Focus();
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.

Re: Put the focus in a AnalogNumeric

Posted: Tue Sep 25, 2012 10:50 am
by phrodo
your code works perfect...

Thank you very much... you save my life....

best regards,

Re: Put the focus in a AnalogNumeric

Posted: Wed Dec 19, 2012 11:16 pm
by T_KNIGHT
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,

Re: Put the focus in a AnalogNumeric

Posted: Thu Dec 20, 2012 9:36 am
by mark.monroe
Please post the exception.

Re: Put the focus in a AnalogNumeric

Posted: Thu Dec 20, 2012 10:12 am
by T_KNIGHT
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,

Re: Put the focus in a AnalogNumeric

Posted: Wed Jul 02, 2014 8:39 am
by douglas
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.

Re: Put the focus in a AnalogNumeric

Posted: Mon Nov 18, 2019 5:19 pm
by zorerkek
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();