It is currently March 28th, 2024, 12:49 pm

RegExp Substitution with InputText

Get help with creating, editing & fixing problems with skins
amein14
Posts: 7
Joined: December 2nd, 2017, 6:55 am

Re: RegExp Substitution with InputText

Post by amein14 »

balala wrote:It is, I think. I'd remove the mentioned OnUpdateAction option from the [MeasureString] measure and would complete the Command1 option of the [MeasureInput] measure with a !SetOption bang to set back the same OnUpdateAction option to the [MeasureString] measure when the string is input (see the !SetOption bang below):
Thank you, now no more link open when refresh or after window startup. BUT i found out, after doing search, the user input will not reset and when we do another search, the same result from first user input. Code that I edit as below..

Code: Select all

[MeasureInput]
Measure=Plugin
Plugin=InputText.dll
X=7
Y=35
W=280
H=23
DefaultValue=""
FontColor=255,255,255,255
SolidColor=30,30,30,255
FontFace=Segoe UI
FontSize=10
AntiAlias=1
FocusDismiss=1
Command1=[!SetVariable ISBN "$UserInput$"][!SetOption MeasureString OnUpdateAction """["http://webpac.kdu.edu.my/search/query?match_1=MUST&term_1=[MeasureString]#SearchCat#"]"""][!UpdateMeasure "MeasureString"]

[MeasureString]
Measure=String
String=#ISBN#
RegExpSubstitute=1
Substitute="^\d{1}(\d*)$":"\1"
DynamicVariables=1
;OnUpdateAction=["http://webpac.kdu.edu.my/search/query?match_1=MUST&term_1=[MeasureString]#SearchCat#"]
UpdateDivider=-1
balala wrote: Add the following LeftMouseDownAction option to the [MeterTitle] meter: LeftMouseDownAction=[!SetOption #CURRENTSECTION# StringStyle "Bold"][!UpdateMeter "#CURRENTSECTION#"][!Redraw]. The !SetOption bang of this option sets the Bold style to the meter when you're pushing the button. When the button is released, the same Normal style should be set back. For this you have to add a similar bang to the LeftMouseUpAction option of the same meter (beside the existing ones): LeftMouseUpAction=[!SetOptionGroup Category FontColor "#*TextOff*#"][color=#FF0000][!SetOption #CURRENTSECTION# StringStyle "Normal"][/color][!SetOption #CURRENTSECTION# FontColor "#*TextOrange*#"][!SetVariable SearchCat "&field_1=t&facet_loc=10000&sort=relevance&theme=kdu"][!UpdateMeter *][!Redraw].

Ok, I already add this code;

Code: Select all

LeftMouseDownAction=[!SetOption #CURRENTSECTION# StringStyle "Bold"][!UpdateMeter "#CURRENTSECTION#"][!Redraw]
LeftMouseUpAction=[!SetOptionGroup Category FontColor "#*TextOff*#"][color=#FF0000][!SetOption #CURRENTSECTION# StringStyle "Normal"][/color][!SetOption #CURRENTSECTION# FontColor "#*TextOrange*#"][!SetVariable SearchCat "&field_1=t&facet_loc=10000&sort=relevance&theme=kdu"][!UpdateMeter *][!Redraw]
and the result:
Image

Can we make bold effect stay bold before we click another meter ( same like orange color effect)?
balala wrote:Or there also is a third possibility, too: to set the string bold when you're hovering the mouse over it, then set it back to normal, when you you're leaving it. Just have to add the appropriate bangs to a newly added MouseOverAction and MouseLeaveAction options. If you can't do this and you're interested, please let me know, to help you.
Got this working with

Code: Select all

MouseLeaveAction=[!SetOption #CURRENTSECTION# StringStyle ""][!UpdateMeter *][!Redraw]
MouseOverAction=[!SetOption #CURRENTSECTION# StringStyle Bold][!UpdateMeter *][!Redraw]
User avatar
balala
Rainmeter Sage
Posts: 16109
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: RegExp Substitution with InputText

Post by balala »

amein14 wrote:BUT i found out, after doing search, the user input will not reset and when we do another search, the same result from first user input. Code that I edit as below..
Sorry, my inattention again. You have to escape the dynamically set variables and measure names into the !SetOption bang (https://docs.rainmeter.net/manual/skins/option-types/#AsteriskEscape). So you have to modify the Command1 option of the [MeasureInput] measure, as it follows: OnUpdateAction """["http://webpac.kdu.edu.my/search/query?match_1=MUST&term_1=[[color=#FF0000]*[/color]MeasureString[color=#FF0000]*[/color]]#[color=#FF0000]*[/color]SearchCat[color=#FF0000]*[/color]#"]"""][!UpdateMeasure "MeasureString"], adding the red marked escaping characters.
amein14 wrote:Can we make bold effect stay bold before we click another meter ( same like orange color effect)?
Yep, we can. For this, I'd completely remove the previously added LeftMouseDownAction options and would complete the LeftMouseUpAction options, as it follows:

Code: Select all

[MeterTitle]
...
LeftMouseUpAction=[!SetOptionGroup Category FontColor "#*TextOff*#"][!SetOption #CURRENTSECTION# StringStyle "Bold"][!SetOption MeterISBN StringStyle "Normal"][!SetOption #CURRENTSECTION# FontColor "#*TextOrange*#"][!SetVariable SearchCat "&field_1=t&facet_loc=10000&sort=relevance&theme=kdu"][!UpdateMeter *][!Redraw]

[MeterISBN]
...
LeftMouseUpAction=[!SetOptionGroup Category FontColor "#*TextOff*#"][!SetOption #CURRENTSECTION# StringStyle "Bold"][!SetOption MeterTitle StringStyle "Normal"][!SetOption #CURRENTSECTION# FontColor "#*TextOrange*#"][!SetVariable SearchCat "&field_1=isbn&facet_loc=10000&sort=relevance&theme=kdu"][!UpdateMeter *][!Redraw]
I didn't post all options of these meters, but you have to leave them untouched.
Probably an even better solution would be to set not the StringStyle option, but the FontWeight, instead. It has a bit more possibilities. But setting the StringStyle is many times enough, I think.
amein14 wrote:Got this working with

Code: Select all

MouseLeaveAction=[!SetOption #CURRENTSECTION# StringStyle ""][!UpdateMeter *][!Redraw]
MouseOverAction=[!SetOption #CURRENTSECTION# StringStyle Bold][!UpdateMeter *][!Redraw]
Replace the [!SetOption #CURRENTSECTION# StringStyle ""] bang with [!SetOption #CURRENTSECTION# StringStyle "[color=#FF0000]Normal[/color]"]. When you want to set normal style for a String meter, you don't have to set it to empty, but to normal. The reason why we don't add the StringStyle=Normal option to each String meter which have to be normal, is that Normal is the default value for this option, so it is set even if explicitely we don't add it to each meter.
amein14
Posts: 7
Joined: December 2nd, 2017, 6:55 am

Re: RegExp Substitution with InputText

Post by amein14 »

balala wrote:Sorry, my inattention again. You have to escape the dynamically set variables and measure names into the !SetOption bang (https://docs.rainmeter.net/manual/skins/option-types/#AsteriskEscape). So you have to modify the Command1 option of the [MeasureInput] measure, as it follows: OnUpdateAction """["http://webpac.kdu.edu.my/search/query?match_1=MUST&term_1=[[color=#FF0000]*[/color]MeasureString[color=#FF0000]*[/color]]#[color=#FF0000]*[/color]SearchCat[color=#FF0000]*[/color]#"]"""][!UpdateMeasure "MeasureString"], adding the red marked escaping characters.
Thank you again balala for you help, yup this fixed it.
balala wrote: Yep, we can. For this, I'd completely remove the previously added LeftMouseDownAction options and would complete the LeftMouseUpAction options, as it follows:

Code: Select all

[MeterTitle]
...
LeftMouseUpAction=[!SetOptionGroup Category FontColor "#*TextOff*#"][!SetOption #CURRENTSECTION# StringStyle "Bold"][!SetOption MeterISBN StringStyle "Normal"][!SetOption #CURRENTSECTION# FontColor "#*TextOrange*#"][!SetVariable SearchCat "&field_1=t&facet_loc=10000&sort=relevance&theme=kdu"][!UpdateMeter *][!Redraw]

[MeterISBN]
...
LeftMouseUpAction=[!SetOptionGroup Category FontColor "#*TextOff*#"][!SetOption #CURRENTSECTION# StringStyle "Bold"][!SetOption MeterTitle StringStyle "Normal"][!SetOption #CURRENTSECTION# FontColor "#*TextOrange*#"][!SetVariable SearchCat "&field_1=isbn&facet_loc=10000&sort=relevance&theme=kdu"][!UpdateMeter *][!Redraw]
I didn't post all options of these meters, but you have to leave them untouched.
Probably an even better solution would be to set not the StringStyle option, but the FontWeight, instead. It has a bit more possibilities. But setting the StringStyle is many times enough, I think.
Noticed that if I want to add more MeterTitle, I just add this

Code: Select all

[!SetOption MeterTitle StringStyle "Normal"]
for the rest and I tried your suggestion with FontWeight 800,working great!
balala wrote:Replace the [!SetOption #CURRENTSECTION# StringStyle ""] bang with [!SetOption #CURRENTSECTION# StringStyle "[color=#FF0000]Normal[/color]"]. When you want to set normal style for a String meter, you don't have to set it to empty, but to normal. The reason why we don't add the StringStyle=Normal option to each String meter which have to be normal, is that Normal is the default value for this option, so it is set even if explicitely we don't add it to each meter.
Noted. Fixed. :D


BTW, while reading some thread, stumble upon with ActionTimer plugin which can create slider like skin.. I would like to try that on this project.
My plan is to create more compact search bar with multiple search options as I set this skin on topmost position.
Image

Havent got complete working code, once I do..maybe I will open another thread for help (if any). :oops:
User avatar
balala
Rainmeter Sage
Posts: 16109
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: RegExp Substitution with InputText

Post by balala »

amein14 wrote:Thank you again balala for you help, yup this fixed it.
I'm glad.
amein14 wrote:Noticed that if I want to add more MeterTitle, I just add this

Code: Select all

[!SetOption MeterTitle StringStyle "Normal"]
for the rest and I tried your suggestion with FontWeight 800,working great!
FontWeight is a newer option and that's why it is much versatile.
amein14 wrote:BTW, while reading some thread, stumble upon with ActionTimer plugin which can create slider like skin.. I would like to try that on this project.
My plan is to create more compact search bar with multiple search options as I set this skin on topmost position.
Image

Havent got complete working code, once I do..maybe I will open another thread for help (if any). :oops:
ActionTimer is a great and powerful plugin. I used it a few times to create animation, without having to set a too low Update value. Many times (depending on the concrete code you're working with) the Update can be set even to -1, completely avoiding this way the update of the skin.
Feel free to ask (here or into a new thread, if needed) about this plugin, probably you'll get some help.
Post Reply