Configurator.. save selected text to a variable

How can I? Within a form in the configurator…
I wonder if you could help me find a bit of code to accomplish the following.
A piece of text within a text box is selected. MouseUp would save it to a variable.
Or…
When clicking a button on the form the selected text is saved to a variable.

Being able to use MouseUp is possible but not within the standard configurator way to do things. You can setup a button but when saving to a variable that will pose some problems depending on the context you want to use that variable in. Are you hoping to save the variable and use it later within other events?

There are not any persistent variables EXCEPT for inputs… so the easiest way to create a variable is to create a new input, but make it “read only” and even (after testing) invisible.
Then… since Epicors “On field Change” code runs whenever you change and leave a field, you can simply put a line of code into the on field change section…
Inputs.MySpecialReadOnlyField.Value = Inputs.Fieldx.Value;

I am looking to parse the value contained within that textbox. All the other attributes I need within that text box are fixed in that I can get to them(parse them out) one way or another. That is except for one. So the only way I can get the value is to ask of the user to select that piece of the text. I have employed your suggestion elsewhere Tim. I’m stuck on how to get only the selected piece of the text to another hidden textbox?

You can access the selected text and I can post an example of how to do that but keep in mind it is something outside of the standard toolbox. There are also ways to store these values without adding additional input controls (i.e. hidden tooltip, etc.).

Well… Google is a miracle worker…
There are many Control values that are in c#… our configurator only exposes some of them (location, length, visibility, etc)… but you can access many others… (Color, font, etc). ONE of those controls is “Selected Text”. I just tested it and it works… i typed “aaabbbbcccc” into a text field, then using the mouse I selected “bbbb” and left the field… only the “bbbb” appeared in my new field.

Inputs.MySpecialReadOnlyField.Value = Inputs.Fieldx.Control.SelectedText;

1 Like

Tim, It sure does! Thank You! I was trying to accomplish it with a SendKeys…

Here are a few other controls I use periodically:
//This sets the focus on the field specified… useful when user clicks a checkbox, you can have the focus change to another field. Found if you do this in the on-field-changed of a combo that the combo it’s in doesn’t correctly populate.
Inputs.MyTextField.Control.Focus();

//Changing foreground and background colors… if you want to do this, you must always turn UseAppStyling to false for this to work. This is a field by field setting.
Inputs.MyButton.ForeColor = Color.Blue;
Inputs.MyButton.Control.UseAppStyling = false;

//Changing Combo Box colors
Inputs.MyCombo.Control.Forecolor Color.Blue;
Inputs.MyCombo.Control.Backcolor Color.Red;
Inputs.MyCombo.Control.UseAppStyling = false;

//I have used this a lot to make sure that the pictures are behind the input fields. you can do the same with the gray boxes to bring them forward or back.
Inputs.epiPcPictureBox1.Control.SendToBack();
Inputs.MyTextField.Control.BringToFront();

//Change Label Fonts… I did this with a heading font, but I think I also tried this out in a field as well. Since our FIELD label fields are not created by us, I don’t know how to access the prompt field for a normal text/decimal/combo/Bool field to change it.
FontFamily family = new FontFamily(“Times New Roman”);
Font font = new Font(family, 20.0f, FontStyle.Bold );
Inputs.MyLabel.Control.BackColor = System.Drawing.Color.Black; //more ugly controls… but can be done
Inputs.MyLabel.Control.ForeColor = System.Drawing.Color.Red; //more ugly controls… but can be done
Inputs.MyLabel.Control.Font = font;
Inputs.MyLabel.Control.UseAppStyling = false;