Read a string from a point - string

Truth is, I don't know if I asked the question correctly, but here is the explanation:
I created a texbox that works as a command line. You enter data and depending on what is written, it will perform several functions: for example: change the color of a panel, button, letter, etc.
Now I try that when I enter "color.Red" the program detects the word "color" and then knows that all that appears after that word is the color that the user wants to change so far it is like this:
if (e.KeyCode == Keys.Enter) // if user presses enter
{
System.Drawing.Color myColor = System.Drawing.ColorTranslator.FromHtml (command_txt.Text); // reads the content of the textbox and passes it to html language that gives us the color
this.BackColor = myColor; // at the end, set this color to the bottom of the form
}
As you can see, I only made the program able to read the color.
Is there a way to run this code only when the user enters "color" + "(whatever color you want)".?

Related

Setting a text view to blank text after being toggled

I have a text view that is clickable. Every time the user clicks the text box, it will display a string. When they click it again, the box will become blank. I have this so far:
textToggle.setOnClickListener {
textToggle.text = "Hello"
}
I have seen some examples where the person did an override on onClick. Would that be the case for here too, or is there a simpler way that I'm not seeing?
Just check the length of the text when you click on it.
textToggle.setOnClickListener {
if(textToggle.text.length > 0) textToggle.text = ""
else textToggle.text = "Hello"
}

A problem for selecting a image from the imagepupop dialog

One more question. If I create a image-popup dialog, I find it only works when the frontimage (the top one in the image list). If other image is selected, the program will report "the image used in the expression does not exist". I can not understand the logic behind this error.
The following is a modified code pasted in the answer of the previous question. It can work well if the first image is selected, but the error message appears if the second image is selected.
I use GSM 2.30.xxxx
Class CMyDLG : UIframe
{
TagGroup DLG,DLGItems,imgPop
object Init(object self)
{
DLG = DLGCreateDialog("Test",DLGItems)
imgPop = DLGCreateImagePopup()
DLGItems.DLGAddElement( imgPop )
return self.super.init(DLG)
}
image GetSelectedImage( object self )
{
string selectedImageLabel
imgPop.DLGGetValue(selectedImageLabel) //DLGGetValue can return the label of the image diretly
Result("\n" + selectedImageLabel)
// From the string, get the label
//string label = selectedImageLabel.left( selectedImageLabel.find(":") )
//Result("\n" + label)
// From label, return image
//return FindImageByLabel(label)
return FindImageByLabel(selectedImageLabel)
}
}
// main
{
object dlg = Alloc(CMyDLG).Init()
dlg.Pose()
image selected = dlg.GetSelectedImage()
if ( selected.ImageIsValid() )
{
selected.SetName( "Selected" + random())
selected.ShowImage()
}
else Throw( "Error, nothing selected." )
}
Using the test code on GMS 3.3 it works except for the bug mentioned. I presume it's the same for GMS 2.3 but I haven't verified.
To make sure we test the same thing, here are exact instructions and a break-down:
Start out with two images A and B and A being front-most.
Run script
Don't change anything in the dialog
Press OK
ERROR
The dialog - taggroup does not (yet) hold any value. It possibly should, I consider this a bug.
Start out with two images A and B and A being front-most.
Run script
Click the selection box and select "A" from the drop-down
Press OK
A is correctly selected
Start out with two images A and B and A being front-most.
Run script
Click the selection box and select "B" from the drop-down
Press OK
ERROR
The dialog - taggroup does not (yet) hold any value. It definitly should, I consider this a bug. It is most likely what you were describing?
Start out with two images A and B and A being front-most.
Run script
Click the selection box and select "A" from the drop-down
Click the selection box and select "B" from the drop-down
Press OK
B is correctly selected
To summarize:
Yes, there is a bug and nothing wrong with your script.
The selection box only works after selecting an items for the second time.
The example code (first script) in this answer seems to work on any of the open images when selected.
However, there is the (mentioned) bug that it does not work on first selection, only when you select one image and then another.
If your code fails, please provided a slimmed-down code-example of the failing code so that a mistake can possibly be spotted.

How can I change the opacity of a button in a if statement in kotlin

I'm making and app and I'm in the register/login, I would like to do something similar as instagram does when the email/username or password are empty or the password does not have enough character (8 or more) the button opacity is reduced and when all is correct is 100%, as I'm starting in kotlin and I don't have any knowledge in java I don't know if this is possible
if(email.isEmpty() || password.isEmpty()){
Toast.makeText(this, "please enter text in email/password",Toast.LENGTH_SHORT).show()
return#setOnClickListener
}
what I'm trying to achieve is that in the if statement when else, opacity of button 50%, when if correct opacity of button 100%
the button is located in activity_register and the button id is registrar_button_register and the
in the if statement also I donĀ“t know how to add that until the password has 8 or more characters the if statement is not completed
could it be done? and how?
To set the opacity for a View, change it's alpha value.
registrar_button_register.alpha = 0.5f
You could even animate the opacity change using animate()
registrar_button_register.animate().alpha(0.5f).setDuration(200)
use this code :
if (your condition) {
yourButton.setAlpha(1f);
} else {
yourButton.setAlpha(0.5f);
}

Formatting Strings in TextField JavaFX

In my JavaFX application I am trying to format a String and then push it to TextField.
This is my code:
String result = "No of Rows Returned : " + repairHeaderEntities.size();
if(null!=repairHeaderEntities && repairHeaderEntities.size()>0){
result = result + "\n" + "\nRepair Status Code: "+entity.getRepairStatusCode();
analyzeResult.setText(result);
analyzeResult is the TextField fx id.
But in the output I am getting the following:
No of Rows Returned : 1Repair Status Code: ENDE
As you can see there output is not moving to a new line and is coming up in the same line.
From the documentation for TextField:
Text input component that allows a user to enter a single line of unformatted text. Unlike in previous releases of JavaFX, support for multi-line input is not available as part of the TextField control, however this is the sole-purpose of the TextArea control.
Use a TextArea in place of the TextField.
If you do not want the user to be able to edit the text in the text control, you could also consider using a Label instead.

How to verify whether a blinking cursor is currently inside of a text box through TestComplete

I am trying to verify that the text box gets the focus (the blinking cursor gets placed inside of it) after a certain action. I tried to use the Focused property, but it does not seem to work, or the object doesnt have this property. This is on a Web application. Here is the code
reportPage = Aliases.iexplore.IESA;
saveWindow = reportPage.Find("ObjectIdentifier", "MainContent_saveFilterSetDialog_saveDialog", 50, true);
saveWindowNameTextBox = saveWindow.Find("ObjectIdentifier", "*MainContent_*_sfsName", 25, true);
if(saveWindowNameTextBox.Focused == true)
Log.Message("The blinking cursor is inside of the name text box")
else
Log.Error("The blinking cursor is not inside of the name text box")
The logging window says "Waiting for Focused", then it fails and the log says "Unable to find the object with the specified properties"
NOTE: When I inspect this text box object in the object inspector window, "Focused" is not listed in the list of properties.
Is there another way to accomplish this?
I was able to accomplish this using an HTML DOM property activeElement
var actualFocusedElement = Sys.Browser().Page("*BC/Report*").contentDocument.activeElement.id
if(aqString.Contains(actualElement, "saveDialog_tmpl_sfsName", 0, true))
Log.Message("The blinking cursor is inside of the name text box")
else
Log.Error("The blinking cursor is not inside of the name text box")

Resources