Active Colors wrote: ↑March 17th, 2022, 11:43 amGotcha. Add/change these:
Code: Select all
[Rainmeter]
OnRefreshAction=[!CommandMeasure TextInput "ExecuteBatch All"]
[TextInput]
DefaultValue=[#DefaultText][\13][\10]
Command2=[!UpdateMeasure *][!UpdateMeter *][!Refresh]
Ok, combining my previous
InputBox skin and this one, I found a relatively reasonable way of endlessly commanding the input text measure to run its batch AND a way to stop it from happening and revert to the normal behavior where
ENTER will commit changes in the edit box, all this within the same skin loading cycle, aka no refresh needed. I say relatively reasonable because it involves estimating how much time will the batch operations take (below, this is set to 200 ms, but it's adjustable from
[Variables]), so that the
Hotkey plugin events, which normally happen before the
InputText plugin ones, get the chance to happen after the latter. I initially added the
State variable just to have a way of logging whether the "return mode" or the "commit mode" was active when pressing
ENTER, but in the end it proved useful to correct adding the
ENTER sequence at all times in this scenario, so now it will add it only when the "return mode" is active. I used
TAB to toggle between these 2 modes, since it doesn't seem to do anything at all when editing in the input text box. The code is as follows:
Code: Select all
[Variables]
Suffix0=
; Empty suffix for an original UserInput
Suffix1=[*\13*][*\10*]
; ENTER suffix for a returning UserInput
State=0
; State = 0 if commits, State = 1 if returns
Delay=200
; Delay to run HotKey after the InputText things
DefaultText="Hello There![\13][\10]How Are You?"
; ENTER for a new line, TAB then ENTER to commit
[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1
BackgroundMode=2
SolidColor=47,47,47,255
SkinWidth=600
SkinHeight=600
---Measures---
[InitInputs]
Measure=Calc
IfCondition=1
IfTrueAction=[!SetOptionGroup InputTextGroup FontFace "Consolas"][!SetOptionGroup InputTextGroup SolidColor "0,0,0,255"][!SetOptionGroup InputTextGroup FontColor "255,255,255,255"][!SetOptionGroup InputTextGroup FontSize 16][!SetOptionGroup InputTextGroup AntiAlias 1][!SetOptionGroup InputTextGroup ClipString 1]
UpdateDivider=-1
DynamicVariables=1
[TextInput]
Group=InputTextGroup
Measure=Plugin
Plugin=InputText
X=[Text:X]
Y=[Text:Y]
W=[Text:W]
H=[Text:H]
DefaultValue="#DefaultText#"
UpdateDivider=-1
Command1=[!SetVariable DefaultText """$UserInput$[#Suffix[#State]]"""][!WriteKeyValue Variables DefaultText """"[#CURRENTSECTION#]""""]
Command2=[!UpdateMeasure #CURRENTSECTION#][!UpdateMeter Text][!Redraw]
OnDismissAction=[!SetVariable State (1-#State#)][!CommandMeasure ENTER Toggle][!Log "ENTER commits = #State#"]
RegExpSubstitute=1
Substitute="\r\n":"#Suffix1#"
DynamicVariables=1
[ENTER]
Measure=Plugin
Plugin=HotKey
HotKey=#CURRENTSECTION#
KeyDownAction=[!Delay #Delay#][!CommandMeasure TextInput "ExecuteBatch All"][!Log "ENTER returns = #State#"]
DynamicVariables=1
[TAB]
Measure=Plugin
Plugin=HotKey
HotKey=#CURRENTSECTION#
KeyDownAction=[!SetVariable State (1-#State#)][!CommandMeasure ENTER Toggle][!Log "ENTER commits = #State#"]
DynamicVariables=1
---Meters---
[Text]
Meter=String
X=10
Y=10
W=580
H=580
SolidColor=0,0,0,255
FontFace=Consolas
FontColor=255,255,255,255
FontSize=16
AntiAlias=1
ClipString=1
Text="#DefaultText#"
UpdateDivider=-1
LeftMouseUpAction=[!SetVariable State 1][!CommandMeasure ENTER Start][!CommandMeasure TextInput "ExecuteBatch All"]
DynamicVariables=1
There is a small bug where dismissing the input text will keep all but the last change to the content, due to the system used, but I let it there since there might be times when ones wants this to happen. For now, the unselecting is more or less the last issue standing, though it could probably be easily corrected if the devs would accept and be able to add an additional option to the measure that controls whether the text is selected or not when the input text is clicked for editing. Of course, they could have added the possiblity to use ENTER as the newline if they wanted or were able to by now, but that's nother matter.
Anyway, I'm sure the unselecting can be done as well through a "hack" of some sort, but for now I'll temporarily put this to pause for some relax - I'll probably take a look at it later on, after I deal with the little bug mentioned earlier. Apparently things work out anyway, one way or another, irrespective if there is someone to tell you whether it can be done or not.
P.S. In an usage scenario, I'd probably use the normal CTRL+ENTER newline, since although inconvenient to the hand, is convenient when it comes to code and its simplicity. But you know, I can't resist challenges, man must beat the machine...