It is currently September 1st, 2024, 1:44 am
Working with InputText
-
- Posts: 442
- Joined: July 30th, 2014, 10:30 am
Re: Working with InputText
is there a way to limit some words-strings to be entered in an InputText box?
-
- Developer
- Posts: 22710
- Joined: April 19th, 2009, 11:02 pm
- Location: Fort Hunt, Virginia, USA
Re: Working with InputText
https://docs.rainmeter.net/manual/plugins/inputtext/#InputLimitPul53dr1v3r wrote: ↑December 4th, 2019, 2:58 pm is there a way to limit some words-strings to be entered in an InputText box?
-
- Posts: 442
- Joined: July 30th, 2014, 10:30 am
Re: Working with InputText
hi Morley. You misunderstood me thx to my mistake. Not to limit number of characters but to prohibit some strings to be entered no matter its length.jsmorley wrote: ↑December 4th, 2019, 3:24 pm https://docs.rainmeter.net/manual/plugins/inputtext/#InputLimit
For example, i don't wan't that these strings are allowed to be a variable name (entered through InputText): jsmorley, pul53dr1v3r .
When i type them in, they shouldn't be accepted and written in the Variable.
Last edited by pul53dr1v3r on December 4th, 2019, 7:30 pm, edited 2 times in total.
-
- Developer
- Posts: 22710
- Joined: April 19th, 2009, 11:02 pm
- Location: Fort Hunt, Virginia, USA
Re: Working with InputText
Not easily. You can't limit what is allowed as a string "before the fact" in any way. I guess you could use an IfMatch on the InputText plugin measure that will evaluate what is entered "after the fact", and take some action, like setting a variable value to "" or "Not Allowed" or something else.Pul53dr1v3r wrote: ↑December 4th, 2019, 4:02 pm hi Morley. You misunderstood me thx to my mistake. Not to limit number of characters but to prohibit some strings to be entered no matter its length.
For example, i don't wan't that these strings are allowed to be a variable name (entered through InputText): jsmorley, pul53dr1v3r .
When i type them in, they should be accepted and written in the Variable.
-
- Rainmeter Sage
- Posts: 16485
- Joined: October 11th, 2010, 6:27 pm
- Location: Gheorgheni, Romania
Re: Working with InputText
EDIT: Sorry jsmorley...
Probably such a possibility doesn't exist, however I suppose a String measure could help. You should transfere the entered string to a String measure and there an IfMatch options set could write or not the strings, depending on their value.Pul53dr1v3r wrote: ↑December 4th, 2019, 4:02 pm hi Morley. You misunderstood me thx to my mistake. Not to limit number of characters but to prohibit some strings to be entered no matter its length.
For example, i don't wan't that these strings are allowed to be a variable name (entered through InputText): jsmorley, pul53dr1v3r .
When i type them in, they should be accepted and written in the Variable.
-
- Developer
- Posts: 22710
- Joined: April 19th, 2009, 11:02 pm
- Location: Fort Hunt, Virginia, USA
Re: Working with InputText
This is about as close as I can see to get, and it's certainly not the same as "not allowing" some input. It's more "throwing away" disallowed input. You simply can't stop the input before the fact, and you can't have it keep the input active and insist that something else be entered.
So if something "not allowed" is entered, it will just beep and throw away the result as soon as the user hits enter. If the text is "allowed", then a variable value is set.
You will need ONE line if IfMatch conditions, with the various text strings separated by a | logical OR symbol. Logic will not allow you to use multiple IfMatch[n] conditions, as the IfNotMatchAction[n] options will fight each other.
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=4
W=200
H=23
SolidColor=0,0,0,1
FontColor=47,47,47,255
FontFace=Fira Sans
FontSize=12
AntiAlias=1
Text=Enter here
LeftMouseUpAction=[!EnableMeasure MeasureInput][!CommandMeasure "MeasureInput" "ExecuteBatch 1"]
[MeasureInput]
Measure=Plugin
Plugin=InputText
X=1
Y=2
W=200
H=22
SolidColor=200,200,200,255
FontColor=47,47,47,255
FontFace=Fira Sans
FontSize=11
AntiAlias=1
FocusDismiss=1
DynamicVariables=1
Disabled=1
UpdateDivider=-1
IfMatch=(?i)^jsmorley$|^pul53dr1v3r$
IfMatchAction=[Play error]
IfNotMatchAction=[!SetVariable MyVar "[MeasureInput]"]
Command1=[$UserInput$][!UpdateMeasure MeasureInput]
You will need ONE line if IfMatch conditions, with the various text strings separated by a | logical OR symbol. Logic will not allow you to use multiple IfMatch[n] conditions, as the IfNotMatchAction[n] options will fight each other.
-
- Posts: 442
- Joined: July 30th, 2014, 10:30 am
Re: Working with InputText
Pul53dr1v3r wrote: ↑December 4th, 2019, 4:02 pm When i type them in, they should be accepted and written in the Variable.
![Jaw Drop :jawdrop](./images/smilies/jawdrop.gif)
@morley, balala
Sorry once again. I meant "When i type them in, they shouldn't be accepted and written in Variable." but you got my intention.
Perfect solution!
![Okay :Ok](./images/smilies/okay.png)
I just had to add 2 more things in the code to get the example completely works:
1. [!WriteKeyValue... to IfNotMatchAction action, since the variable had not been changed for me using only SetVariable,
2. Command2=[!RefreshGroup "Test"], because the sound wouldn't play if 2 or more prohibited values are entered in a session.
![Rose Gift :rosegift:](./images/smilies/ax.gif)
Code: Select all
[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1
Group=Test
[Variables]
MyVar=55555
[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=4
W=200
H=23
SolidColor=0,0,0,1
FontColor=47,47,47,255
FontFace=Fira Sans
FontSize=12
AntiAlias=1
Text=Enter here
LeftMouseUpAction=[!EnableMeasure MeasureInput][!CommandMeasure "MeasureInput" "ExecuteBatch 1-2"]
[MeasureInput]
Measure=Plugin
Plugin=InputText
X=1
Y=2
W=200
H=22
SolidColor=200,200,200,255
FontColor=47,47,47,255
FontFace=Fira Sans
FontSize=11
AntiAlias=1
FocusDismiss=1
DynamicVariables=1
Disabled=1
UpdateDivider=-1
IfMatch=(?i)^jsmorley$|^pul53dr1v3r$
IfMatchAction=[Play error]
IfNotMatchAction=[!WriteKeyValue Variables MyVar "[MeasureInput]"][!SetVariable MyVar "[MeasureInput]"]
Command1=[$UserInput$][!UpdateMeasure MeasureInput]
Command2=[!RefreshGroup "Test"]
-
- Posts: 442
- Joined: July 30th, 2014, 10:30 am
Re: Working with InputText
if a forbidden string is language tag, for example en-GB, how to prevent opening Windows language folder (C:\Windows\System32\en-GB) whenever i enter the tag in the InbutText box?
-
- Developer
- Posts: 22710
- Joined: April 19th, 2009, 11:02 pm
- Location: Fort Hunt, Virginia, USA
Re: Working with InputText
I don't follow that a bit.Pul53dr1v3r wrote: ↑December 4th, 2019, 11:00 pm if a forbidden string is language tag, for example en-GB, how to prevent opening Windows language folder (C:\Windows\System32\en-GB) whenever i enter the tag in the InbutText box?
-
- Rainmeter Sage
- Posts: 5495
- Joined: April 12th, 2012, 9:40 pm
- Location: Cedar Point, Ohio, USA
Re: Working with InputText
Even though the $UserInput$ matches a forbidden text, the [MeasureInput] batch commands are still going to be executed...Pul53dr1v3r wrote: ↑December 4th, 2019, 11:00 pm if a forbidden string is language tag, for example en-GB, how to prevent opening Windows language folder (C:\Windows\System32\en-GB) whenever i enter the tag in the InbutText box?
I would suggest writing the $UserInput$ to #MyVar# no matter what it is and creating a separate measure to test and take actions based on those results (as suggested by balala).
This will not execute the $UserInput$ if it matches one of the "forbidden text" and will set #MyVar# to "" if it does.
Code: Select all
[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1
Group=Test
[Variables]
MyVar=55555
[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=4
W=200
H=23
SolidColor=0,0,0,1
FontColor=47,47,47,255
FontFace=Fira Sans
FontSize=12
AntiAlias=1
Text=Enter here
LeftMouseUpAction=[!EnableMeasure MeasureInput][!CommandMeasure "MeasureInput" "ExecuteBatch 1"]
[MeasureInput]
Measure=Plugin
Plugin=InputText
X=1
Y=2
W=200
H=22
SolidColor=200,200,200,255
FontColor=47,47,47,255
FontFace=Fira Sans
FontSize=11
AntiAlias=1
FocusDismiss=1
DynamicVariables=1
Disabled=1
UpdateDivider=-1
Command1=[!WriteKeyValue Variables MyVar "$UserInput$"][!SetVariable MyVar "[MeasureInput]"][!EnableMeasure MeasureInputAction][!UpdateMeasure MeasureInputAction]
;Command2=[!RefreshGroup "Test"]
[MeasureInputAction]
DynamicVariables=1
Measure=String
String=#MyVar#
IfMatch=(?i)^jsmorley$|^pul53dr1v3r$|^en-gb$
IfMatchAction=[!DisableMeasure MeasureInput][!WriteKeyValue Variables MyVar ""][Play error]
IfNotMatchAction=["#MyVar#"][!RefreshGroup "Test"]
Disabled=1
:: My DA Gallery :: Rainmeter DA Gallery :: Rainmeter Workshops :: Rainmeter Documentation :: BBCode Guide ::