It is currently August 12th, 2020, 12:58 am

Working with InputText

Our most popular Tips and Tricks from the Rainmeter Team and others
User avatar
jsmorley
Developer
Posts: 21240
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Working with InputText

Post by jsmorley »

Yamajac wrote: December 5th, 2019, 9:38 pm I haven't looked into it but doesn't the inputtext plugin store the last value it had, so you'd be able to do IfMatch just right on the input textplugin instead?
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.
User avatar
jsmorley
Developer
Posts: 21240
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Working with InputText

Post by jsmorley »

Actually, I like this better...

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]
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...
User avatar
pul53dr1v3r
Posts: 399
Joined: July 30th, 2014, 10:30 am

Re: Working with InputText

Post by pul53dr1v3r »

sorry for the confusion. i'm guilty because i sometimes don't think with my head. :Whistle

Thank you Morley for the solution, it does just the job. i've used the last one. :rosegift:
Thank you ET too and sorry for my, probably a bit rough reply. :rosegift:
I deserve :x at best.