Put the focus in a AnalogNumeric

A forum devoted to the discussion of all topics having to do with scripting and other advanced programming using iX Developer.
Post Reply
phrodo
Posts: 11
Joined: Mon Sep 24, 2012 9:08 am

Put the focus in a AnalogNumeric

Post 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

Patrick Hall
Posts: 22
Joined: Fri May 25, 2012 7:44 am
Location: Charlotte, NC. USA

Re: Put the focus in a AnalogNumeric

Post 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.
Best Regards,
Patrick Hall

phrodo
Posts: 11
Joined: Mon Sep 24, 2012 9:08 am

Re: Put the focus in a AnalogNumeric

Post by phrodo »

your code works perfect...

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

best regards,

T_KNIGHT
Posts: 2
Joined: Wed Dec 19, 2012 11:00 pm

Re: Put the focus in a AnalogNumeric

Post 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,

mark.monroe
Posts: 824
Joined: Tue Mar 13, 2012 9:53 am

Re: Put the focus in a AnalogNumeric

Post by mark.monroe »

Please post the exception.
Best Regards,
Mark Monroe

Beijer Electronics, Inc. | Applications Engineer

T_KNIGHT
Posts: 2
Joined: Wed Dec 19, 2012 11:00 pm

Re: Put the focus in a AnalogNumeric

Post 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,

douglas
Posts: 1
Joined: Thu Jun 26, 2014 2:33 pm

Re: Put the focus in a AnalogNumeric

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

zorerkek
Posts: 1
Joined: Mon Nov 18, 2019 4:37 pm

Re: Put the focus in a AnalogNumeric

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

Post Reply