It is currently September 16th, 2024, 10:30 am

Unfocusing skin when entering InputText field

Report bugs with the Rainmeter application and suggest features.
User avatar
balala
Rainmeter Sage
Posts: 16544
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Unfocusing skin when entering InputText field

Post by balala »

Hello Everybody,

Just found something which I can't deal with. It is definitely something weird, maybe there is a reasonable explanation, but I couldn't find it, so maybe some one has an idea.

Issue: when I click the meter on which is set the !CommandMeasure bang of an InputText plugin measure, with the ExecuteBatch, the skin gets unfocused, even if has been clicked and I can enter the desired value. When hit Enter, the skin gets focused again, however while entering the value from the keyboard, the skin stays unfocused. Is this the desired behaviour?

Example code:

Code: Select all

[Rainmeter]
Update=1000
OnFocusAction=[!SetVariable Focused "1"][!UpdateMeasure "MeasureFocused"]
OnUnfocusAction=[!SetVariable Focused "0"][!UpdateMeasure "MeasureFocused"]

[Variables]
First=Is this focused?
FontSize=14
Focused=1

[MeasureFocused]
Measure=Calc
Formula=#Focused#
IfCondition=(#CURRENTSECTION#>=1)
IfTrueAction=[!SetOption MeterState Text "Focused"][!SetOption MeterBackground SolidColor "0,0,0,150"][!UpdateMeter "MeterState"][!UpdateMeter "MeterBackground"][!Redraw]
IfFalseAction=[!SetOption MeterState Text "Unfocused"][!SetOption MeterBackground SolidColor "255,0,0,150"][!UpdateMeter "MeterState"][!UpdateMeter "MeterBackground"][!Redraw]
DynamicVariables=1

[MeterBackground]
Meter=Image
SolidColor=0,0,0,150
W=250
H=65

[MeasureInput]
Measure=Plugin
Plugin=InputText
SolidColor=118,160,232
FontColor=255,255,255,255
FontFace=Seqoe UI
StringStyle=Italic
FontSize=#FontSize#
X=5
Y=5
H=25
W=240
DefaultValue=Enter something
Command1=[!SetVariable First "$UserInput$"][!UpdateMeter "MeterFirst"][Redraw]

[MeterFirst]
Meter=String
X=5
Y=5
FontSize=15
FontColor=255,255,255,255
AntiAlias=1
Text=#First#
LeftMouseUpAction=[!CommandMeasure "MeasureInput" "ExecuteBatch 1"]
DynamicVariables=1

[MeterState]
Meter=String
X=0r
Y=5R
FontSize=15
FontColor=255,255,255,255
AntiAlias=1
When you activate the skin with the above code, it is focused. This is stated on the second line of the skin (Focused) and the color of background (black for focused, red for unfocused). The state of the skin can be followed this way and it is proper as long as you don't click the Is this Focused? string, used to execute the InputText plugin, to enter a value from the keyboard. If you do this, the skin get stating it is unfocused, even if you can enter the value from the keyboard.
Is this normal?
User avatar
jsmorley
Developer
Posts: 22745
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Unfocusing skin when entering InputText field

Post by jsmorley »

If I understand you correctly, the answer is yes. Perhaps "desired" isn't the best word, but "unavoidable" might be. The problem is the InputText field is actually a separate Windows input control, and when it is active, IT has the focus, and not the skin window.
User avatar
balala
Rainmeter Sage
Posts: 16544
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Unfocusing skin when entering InputText field

Post by balala »

jsmorley wrote: August 28th, 2024, 8:10 pm If I understand you correctly, the answer is yes. Perhaps "desired" isn't the best word, but "unavoidable" might be. The problem is the InputText field is actually a separate Windows input control, and when it is active, IT has the focus, and not the skin window.
Good point. Yep, this was the question and this way it makes sense, even if right now it is a problem for me. But thanks for the details.
User avatar
jsmorley
Developer
Posts: 22745
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Unfocusing skin when entering InputText field

Post by jsmorley »

balala wrote: August 28th, 2024, 8:44 pm Good point. Yep, this was the question and this way it makes sense, even if right now it is a problem for me. But thanks for the details.
InputText is a quirky beast I'm afraid.
User avatar
Yincognito
Rainmeter Sage
Posts: 8146
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Unfocusing skin when entering InputText field

Post by Yincognito »

balala wrote: August 28th, 2024, 8:44 pm even if right now it is a problem for me
Well, you could set an additional variable just before commanding the measure to execute, and do it in such a way to suggest that the skin is still focused, and of course set it back to the opposite value once the input has been entered or the input text has been dismissed. Then, when testing the focused state of the skin, you'd use both the OnFocusAction / OnUnfocusAction (if that's what you do) OR the value of that additional variable. Not sure of what and how exactly is your scenario, but you get the idea. After all, it's just some value telling you if the skin is focused, it doesn't have to come exclusively from the built-in Rainmeter events, you could "fake" it for this case via the additional variable... :???:
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
balala
Rainmeter Sage
Posts: 16544
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Unfocusing skin when entering InputText field

Post by balala »

jsmorley wrote: August 28th, 2024, 8:45 pm InputText is a quirky beast I'm afraid.
No, it's not, even if there are some weird things. But it's quite useful.
Yincognito wrote: August 28th, 2024, 9:03 pm Well, you could set an additional variable just before commanding the measure to execute, and do it in such a way to suggest that the skin is still focused, and of course set it back to the opposite value once the input has been entered or the input text has been dismissed. Then, when testing the focused state of the skin, you'd use both the OnFocusAction / OnUnfocusAction (if that's what you do) OR the value of that additional variable. Not sure of what and how exactly is your scenario, but you get the idea.
Yep, I get. And had a similar thought as well, but didn't try it out so far. But definitely have to try it and will sooner or later. Thanks for the tip.
User avatar
Yincognito
Rainmeter Sage
Posts: 8146
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Unfocusing skin when entering InputText field

Post by Yincognito »

balala wrote: August 29th, 2024, 11:41 am Yep, I get. And had a similar thought as well, but didn't try it out so far. But definitely have to try it and will sooner or later. Thanks for the tip.
No problem, wish you good luck with it! :great:

P.S. There is also the possibility of trying to replicate an InputText using strictly Rainmeter elements and the HotKey plugin (I have some sample on that somewhere on the forum), which will not unfocus the skin, but obviously that would be trickier and require a greater amount of work, so you'd probably want to avoid that.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
balala
Rainmeter Sage
Posts: 16544
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Unfocusing skin when entering InputText field

Post by balala »

Yincognito wrote: August 29th, 2024, 12:02 pm P.S. There is also the possibility of trying to replicate an InputText using strictly Rainmeter elements and the HotKey plugin (I have some sample on that somewhere on the forum), which will not unfocus the skin, but obviously that would be trickier and require a greater amount of work, so you'd probably want to avoid that.
I definitely want. No, first option is the previously mentioned thing, second is nothing. I mean that since this is something I want to add to an old skin, if that doesn't work, I skip this and keep the skin as it is. But thanks for all the ideas.
User avatar
Yincognito
Rainmeter Sage
Posts: 8146
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Unfocusing skin when entering InputText field

Post by Yincognito »

balala wrote: August 29th, 2024, 2:00 pm I definitely want. No, first option is the previously mentioned thing, second is nothing. I mean that since this is something I want to add to an old skin, if that doesn't work, I skip this and keep the skin as it is. But thanks for all the ideas.
Sure thing. Was just saying, you know, to show the "many ways to skin a cat", so to speak. ;-)
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
balala
Rainmeter Sage
Posts: 16544
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Unfocusing skin when entering InputText field

Post by balala »

Yincognito wrote: August 28th, 2024, 9:03 pm Well, you could set an additional variable just before commanding the measure to execute, and do it in such a way to suggest that the skin is still focused, and of course set it back to the opposite value once the input has been entered or the input text has been dismissed. Then, when testing the focused state of the skin, you'd use both the OnFocusAction / OnUnfocusAction (if that's what you do) OR the value of that additional variable. Not sure of what and how exactly is your scenario, but you get the idea. After all, it's just some value telling you if the skin is focused, it doesn't have to come exclusively from the built-in Rainmeter events, you could "fake" it for this case via the additional variable... :???:
Done, I hope. Still testing, but it seems to be working. So, thanks for the suggestion (once again).