The problem is that you have to use the $UserInput$ macro in the context of a bang, or it is just "executed". I really need to use !SetOption, since you can't use IfMatch on [Variables], so since I am setting the String measure anyway, might as well do the test there.
It is currently August 31st, 2024, 11:52 pm
Working with InputText
-
- Developer
- Posts: 22710
- Joined: April 19th, 2009, 11:02 pm
- Location: Fort Hunt, Virginia, USA
Re: Working with InputText
-
- Developer
- Posts: 22710
- Joined: April 19th, 2009, 11:02 pm
- Location: Fort Hunt, Virginia, USA
Re: Working with InputText
Actually, I like this better...
It's pretty much exactly what I started with, but instead of just using [$UserInput$] in the Command1 option, which would be executed, I just use the macro in the context of a !SetVariable bang that really doesn't do anything but throw the raw input value into a variable that is never used. At the same time the value of [MeasureInput] will be set to the string the user input, and that can be tested right there and then.
I also added IfMatchMode=1, so it doesn't require the test to change from "true" to "false", and added |^$ as another excluded string, so if they hit enter without typing anything, that is ignored.
In any case, now inputting "en-US" does not open the language folder...
Code: Select all
[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1
[Variables]
MyVar=Starting Value
[MeterSearchBox]
Meter=Shape
Shape=Rectangle 1,1,202,25 | Fill Color 215,215,215,255 | Stroke Color 130,130,130,255
W=202
H=25
[MeterSearchLabel]
Meter=String
X=5
Y=5
W=200
H=23
SolidColor=0,0,0,1
FontColor=47,47,47,255
FontSize=12
AntiAlias=1
DynamicVariables=1
StringCase=Upper
Text=#MyVar#
LeftMouseUpAction=[!EnableMeasure MeasureInput][!CommandMeasure "MeasureInput" "ExecuteBatch 1"]
[MeasureInput]
Measure=Plugin
Plugin=InputText
X=5
Y=3
W=197
H=21
SolidColor=200,200,200,255
FontColor=47,47,47,255
FontSize=11
AntiAlias=1
FocusDismiss=1
DynamicVariables=1
Disabled=1
UpdateDivider=-1
IfMatchMode=1
IfMatch=(?i)^jsmorley$|^pul53dr1v3r$|^$
IfMatchAction=[Play error]
IfNotMatchAction=[!SetVariable MyVar "[MeasureInput]"]
Command1=[!SetVariable RawInput "$UserInput$"][!UpdateMeasure MeasureInput]
I also added IfMatchMode=1, so it doesn't require the test to change from "true" to "false", and added |^$ as another excluded string, so if they hit enter without typing anything, that is ignored.
In any case, now inputting "en-US" does not open the language folder...
-
- Posts: 442
- Joined: July 30th, 2014, 10:30 am
Re: Working with InputText
sorry for the confusion. i'm guilty because i sometimes don't think with my head.
Thank you Morley for the solution, it does just the job. i've used the last one.
Thank you ET too and sorry for my, probably a bit rough reply.
I deserve
at best.
![Whistle :Whistle](./images/smilies/whistling.gif)
Thank you Morley for the solution, it does just the job. i've used the last one.
![Rose Gift :rosegift:](./images/smilies/ax.gif)
Thank you ET too and sorry for my, probably a bit rough reply.
![Rose Gift :rosegift:](./images/smilies/ax.gif)
I deserve
![Mad :x](./images/smilies/angry.gif)
-
- Posts: 442
- Joined: July 30th, 2014, 10:30 am
Re: Working with InputText
How to get rid of showing a part of CommandN code in a text field when there is no value entered in it?
For instance, i have this case:
So, the Clamp option is used to limit input number range, but when the MeterInputTxt1 variable is empty, i get (Clamp(,1,10)) in the field.
For instance, i have this case:
Code: Select all
[MeasureInputTxt1]
Measure=Plugin
Plugin=InputText
FontSize=10
InputNumber=1
InputLimit=2
FocusDismiss=1
FontColor=255,255,255
SolidColor=50,50,50
X=10
Y=10
W=10
H=10
DynamicVariables=1
DefaultValue=#MeterInputTxt1#
Command1=[!WriteKeyValue Variables MeterInputTxt1 "(Clamp($UserInput$,1,10))" "#@#Variables.inc"]
Command2=[!RefreshGroup "Group1"]
[MeterInputField1]
Meter=Shape
X=10
Y=10
MeterStyle=StyleInputBox
LeftMouseUpAction=[!CommandMeasure MeasureInputTxt1 "ExecuteBatch 1-2"]
[MeterInputTxt1]
Meter=String
MeterStyle=StyleInputTxt
Text=#MeterInputTxt1#
-
- Moderator
- Posts: 1295
- Joined: February 16th, 2012, 3:32 am
- Location: Berlin, Germany
Re: Working with InputText
This way it is treating it as a part of the string and this is how it works in many places https://docs.rainmeter.net/manual-beta/formulas/.pul53dr1v3r wrote: ↑February 15th, 2021, 12:10 pm How to get rid of showing a part of CommandN code in a text field when there is no value entered in it?
For instance, i have this case:
So, the Clamp option is used to limit input number range, but when the MeterInputTxt1 variable is empty, i get (Clamp(,1,10)) in the field.Code: Select all
[MeasureInputTxt1] Measure=Plugin Plugin=InputText FontSize=10 InputNumber=1 InputLimit=2 FocusDismiss=1 FontColor=255,255,255 SolidColor=50,50,50 X=10 Y=10 W=10 H=10 DynamicVariables=1 DefaultValue=#MeterInputTxt1# Command1=[!WriteKeyValue Variables MeterInputTxt1 "(Clamp($UserInput$,1,10))" "#@#Variables.inc"] Command2=[!RefreshGroup "Group1"] [MeterInputField1] Meter=Shape X=10 Y=10 MeterStyle=StyleInputBox LeftMouseUpAction=[!CommandMeasure MeasureInputTxt1 "ExecuteBatch 1-2"] [MeterInputTxt1] Meter=String MeterStyle=StyleInputTxt Text=#MeterInputTxt1#
Before writing your value to Variables you can !SetVariable YourValueToBeClamped and run a measure to clamp it and the result to write further. It is some extra steps but it is not that hard I think.
-
- Rainmeter Sage
- Posts: 16485
- Joined: October 11th, 2010, 6:27 pm
- Location: Gheorgheni, Romania
Re: Working with InputText
As Active Colors said, you have to add a Calc measure, something like this:pul53dr1v3r wrote: ↑February 15th, 2021, 12:10 pm So, the Clamp option is used to limit input number range, but when the MeterInputTxt1 variable is empty, i get (Clamp(,1,10)) in the field.
Code: Select all
[MeasureMyLimit]
Measure=Calc
Formula=#MeterInputTxt1#
RegExpSubstitute=1
Substitute="^$":"0"
OnChangeAction=[!WriteKeyValue Variables MeterInputTxt1 "(Clamp([MeasureMyLimit],1,10))" "#@#Variables.inc"]
DynamicVariables=1
UpdateDivider=-1
This way, if you're entering an empty string, you get written 1 (the lower limit of the Clamp function).
-
- Posts: 442
- Joined: July 30th, 2014, 10:30 am
Re: Working with InputText
@ AC, Balala
yes, it does the job but... an additional measure. I feel like there is a plugin option to prevent this from happening.
Thanks for the solution.
yes, it does the job but... an additional measure. I feel like there is a plugin option to prevent this from happening.
![Confused :???:](./images/smilies/bw.gif)
Thanks for the solution.
-
- Rainmeter Sage
- Posts: 16485
- Joined: October 11th, 2010, 6:27 pm
- Location: Gheorgheni, Romania
Re: Working with InputText
No, I doubt there would be. This is how you have to do this, I don't see another way.pul53dr1v3r wrote: ↑February 15th, 2021, 5:43 pm yes, it does the job but... an additional measure. I feel like there is a plugin option to prevent this from happening.![]()
-
- Moderator
- Posts: 1295
- Joined: February 16th, 2012, 3:32 am
- Location: Berlin, Germany
Re: Working with InputText
I agree with balala's statement above but just in case you don't need to have extra measure per each of your input element. I don't know how many of those you have but considering the form MeasureInputTxt1 I guess there are more alike input elements. You just need to have only one such measure for the entire skin. Just pass your value from any input to the measure like balala explained. If you need any further help let us know.pul53dr1v3r wrote: ↑February 15th, 2021, 5:43 pm @ AC, Balala
yes, it does the job but... an additional measure. I feel like there is a plugin option to prevent this from happening.![]()
Thanks for the solution.
-
- Posts: 442
- Joined: July 30th, 2014, 10:30 am
Re: Working with InputText
i just had in my mind a plugin option to set a minimal number of characters in an input text measure as leaving it empty can cause errors in certain cases, especially where numeric values are required. Adding additional measure for every InputText measure could be a headache for those who use the plugin. The option should return the last entered value if the number of entered characters is less than the determined with the option.
If InputLimit option (for max number of characters) is necessary, why not to add this one? Can't InputLimit be achieved without the option? It can, but that's much easier way for many users, less code, resource usage...
Just a suggestion for devs with a BIG thanks for all the work up to now!
If InputLimit option (for max number of characters) is necessary, why not to add this one? Can't InputLimit be achieved without the option? It can, but that's much easier way for many users, less code, resource usage...
Just a suggestion for devs with a BIG thanks for all the work up to now!