Well, if you only use Text="%1" and nothing different, i mean for exmpl Text="%1 - %2 |%3", then you can remove Text="%1" from metters, text should be shown anyway, and you can use this example. But if not then lua script will need to some changeslysy1993lbn wrote:Unfortunetly Text=%1 is exacly what I use
It is currently May 2nd, 2024, 10:15 pm
Show tooltip only if text clipped?
-
- Posts: 366
- Joined: November 12th, 2009, 4:47 pm
- Location: Ukraine
Re: Show tooltip only if text clipped?
-
- Posts: 366
- Joined: November 12th, 2009, 4:47 pm
- Location: Ukraine
Re: Show tooltip only if text clipped?
I've rewrite example and now it involvesText="%1" and also using this approach you don't have to create many script measures in skin for each Metter. I did so to make code simple (convinient) to use. Look at the code, hope you'll understand why, but if not, ask for what you don't understand and I, or rainmeter's gurus will answer you
Skin
Lua Script
Skin
Code: Select all
[Rainmeter]
Update=1000
DynamicWindowSize=1
[Variables]
String="Hello i am a very very very long string"
String2="short string"
;--------------------------------------------
[CHCD]
Measure=Script
ScriptFile="#CURRENTPATH#ch_mcd.lua"
Meterlength=MeterToGetStringWidth
MeterToCheck=TestMeter
MeasureToCheck=TestMeasure1
UpdateDivider=-1
[MeterToGetStringWidth]
Meter=String
X=-3000
Y=-1000
Hidden=0
UpdateDivider=-1
;------------------------------------------
[TestMeasure1]
Measure=TIME
Format=#String#
[TestMeasure2]
Measure=TIME
Format=#String2#
[TestMeasure3]
Measure=TIME
Format=#String#
[TestMeter]
Meter=String
MeasureName=TestMeasure1
X=0
Y=0
W=100
H=14
ToolTipText="%1"
ToolTipHidden=1
FontColor=255,255,255
SolidColor=0,0,0,1
Hidden=0
Text="%1"
ClipString=1
MouseOverAction=!execute [!SetOption CHCD MeterToCheck #CURRENTSECTION#][!SetOption CHCD MeasureToCheck TestMeasure1][!UpdateMeasure CHCD]
[TestMeter2]
Meter=String
MeasureName=TestMeasure2
X=0
Y=20r
W=100
H=14
ToolTipText="%1"
ToolTipHidden=1
FontColor=255,255,255
SolidColor=0,0,0,1
Hidden=0
Text="%1"
ClipString=1
MouseOverAction=!execute [!SetOption CHCD MeterToCheck #CURRENTSECTION#][!SetOption CHCD MeasureToCheck TestMeasure2][!UpdateMeasure CHCD]
[TestMeter3]
Meter=String
MeasureName=TestMeasure3
X=0
Y=20r
W=100
H=14
ToolTipText="%1"
ToolTipHidden=1
FontColor=255,255,255
SolidColor=0,0,0,1
Hidden=0
Text="%1"
ClipString=1
MouseOverAction=!execute [!SetOption CHCD MeterToCheck #CURRENTSECTION#][!SetOption CHCD MeasureToCheck TestMeasure3][!UpdateMeasure CHCD]
Code: Select all
PROPERTIES =
{
}
function Initialize()
end -->Initialize
function Update()
sMeterSetting1,sMeterSetting2 = SELF:GetOption('Meterlength'),SELF:GetOption('MeterToCheck')
sMeasureSetting = SELF:GetOption('MeasureToCheck')
sMeasure = SKIN:GetMeasure(sMeasureSetting)
Val0 = sMeasure:GetStringValue()
SKIN:Bang("!SetOption "..sMeterSetting1.." Text \"\"\"" ..Val0.."\"\"\""); SKIN:Bang("!UpdateMeter "..sMeterSetting1); SKIN:Bang("!Redraw")
sMeter1,sMeter2 = SKIN:GetMeter(sMeterSetting1),SKIN:GetMeter(sMeterSetting2)
Val1,Val2,Val2_1 = sMeter1:GetW(),sMeter2:GetOption('Text'),tonumber(sMeter2:GetW())
if Val1 >= Val2_1 then
SKIN:Bang("!SetOption "..sMeterSetting2.." ToolTipHidden 0")
SKIN:Bang("!UpdateMeter "..sMeterSetting2)
SKIN:Bang("!Redraw")
else
SKIN:Bang("!SetOption "..sMeterSetting2.." ToolTipHidden 1")
SKIN:Bang("!UpdateMeter "..sMeterSetting2)
SKIN:Bang("!Redraw")
end
end -->Update
-
- Posts: 291
- Joined: July 25th, 2011, 9:53 am
- Location: Lublin, Poland
Re: Show tooltip only if text clipped?
Thanks ~Faradey~.. Semms to works fine, but.. do i need 20 script measures to make it work in 20 separate meters?
I'm bit confused..
Sorry if it's a stupid question but i don't know lua scripting at all..
I'm bit confused..
Sorry if it's a stupid question but i don't know lua scripting at all..
"Never argue with an idiot, he will drag you down to his level and beat you with experience."
my deviantART | Alternative Rainmeter tray icons
my deviantART | Alternative Rainmeter tray icons
-
- Posts: 366
- Joined: November 12th, 2009, 4:47 pm
- Location: Ukraine
Re: Show tooltip only if text clipped?
Of Course not, as i wrote earlier in my post:
all you need to add in your skin is this little part of code:
and lua script ch_mcd.lua itself (in scin's directory ,you can change the path if you want, just edit ScriptFile="#CURRENTPATH#ch_mcd.lua" to where you want it)
also in metter where you want to use this feature, you need to add OnMouseOverAction and use bang with next syntax:
MouseOverAction=!execute [!SetOption CHCD MeterToCheck NameOfMeter][!SetOption CHCD MeasureToCheck NameOfMeasure][!UpdateMeasure CHCD]
hope now you get the point)
so i repeat, you don't have to!~Faradey~ wrote: using this approach you don't have to create many script measures in skin for each Metter
all you need to add in your skin is this little part of code:
Code: Select all
;--------------------------------------------
[CHCD]
Measure=Script
ScriptFile="#CURRENTPATH#ch_mcd.lua"
Meterlength=MeterToGetStringWidth
MeterToCheck=TestMeter
MeasureToCheck=TestMeasure1
UpdateDivider=-1
[MeterToGetStringWidth]
Meter=String
X=-3000
Y=-1000
Hidden=0
UpdateDivider=-1
;------------------------------------------
also in metter where you want to use this feature, you need to add OnMouseOverAction and use bang with next syntax:
MouseOverAction=!execute [!SetOption CHCD MeterToCheck NameOfMeter][!SetOption CHCD MeasureToCheck NameOfMeasure][!UpdateMeasure CHCD]
hope now you get the point)
-
- Moderator
- Posts: 1931
- Joined: January 29th, 2010, 1:43 am
- Location: Willmar, MN
Re: Show tooltip only if text clipped?
Here's a slightly simplified version:
Skin.ini
Lua.lua:
This version retrieves the MeasureName from the meter itself. No need to specify it to the script at all.
Note: This script requires Rainmeter 2.3 beta r1377 or higher.
Skin.ini
Code: Select all
[Rainmeter]
Update=1000
DynamicWindowSize=1
[Variables]
String="Hello i am a very very very long string"
String2="short string"
;--------------------------------------------
[CHCD]
Measure=Script
ScriptFile=Lua.lua
Meterlength=MeterToGetStringWidth
UpdateDivider=-1
[MeterToGetStringWidth]
Meter=String
X=-3000
Y=-1000
UpdateDivider=-1
;------------------------------------------
[TestMeasure1]
Measure=TIME
Format=#String#
[TestMeasure2]
Measure=TIME
Format=#String2#
[TestMeasure3]
Measure=TIME
Format=#String#
[TestMeter]
Meter=String
MeasureName=TestMeasure1
X=0
Y=0
W=100
H=14
ToolTipText="%1"
ToolTipHidden=1
FontColor=255,255,255
SolidColor=0,0,0,1
ClipString=1
MouseOverAction=!CommandMeasure CHCD ToolTip('#CURRENTSECTION#')
[TestMeter2]
Meter=String
MeasureName=TestMeasure2
X=0
Y=20r
W=100
H=14
ToolTipText="%1"
ToolTipHidden=1
FontColor=255,255,255
SolidColor=0,0,0,1
ClipString=1
MouseOverAction=!CommandMeasure CHCD ToolTip('#CURRENTSECTION#')
[TestMeter3]
Meter=String
MeasureName=TestMeasure3
X=0
Y=20r
W=100
H=14
ToolTipText="%1"
ToolTipHidden=1
FontColor=255,255,255
SolidColor=0,0,0,1
ClipString=1
MouseOverAction=!CommandMeasure CHCD ToolTip('#CURRENTSECTION#')
Code: Select all
function Initialize()
LengthName=SELF:GetOption('MeterLength')
LengthHandle=SKIN:GetMeter(LengthName)
end
function ToolTip(MeterName)
local MeterHandle=SKIN:GetMeter(MeterName)
local Measure=SKIN:GetMeasure(MeterHandle:GetOption('MeasureName'))
SKIN:Bang('!SetOption',LengthName,'Text',Measure:GetStringValue())
SKIN:Bang('!UpdateMeter',LengthName)
SKIN:Bang('!Redraw')
SKIN:Bang('!SetOption',MeterName,'ToolTipHidden',LengthHandle:GetW() >= MeterHandle:GetW and 0 or 1)
SKIN:Bang('!UpdateMeter',MeterName)
SKIN:Bang('!Redraw')
end -- ToolTip
Note: This script requires Rainmeter 2.3 beta r1377 or higher.
GitHub | DeviantArt | Tumblr
This is the song that never ends. It just goes on and on my friends. Some people started singing it not knowing what it was, and they'll continue singing it forever just because . . .
This is the song that never ends. It just goes on and on my friends. Some people started singing it not knowing what it was, and they'll continue singing it forever just because . . .
-
- Posts: 291
- Joined: July 25th, 2011, 9:53 am
- Location: Lublin, Poland
Re: Show tooltip only if text clipped?
Sorry.. still don't understand half this trick..
Do i needFor all meters?
It's measure output so it has to be Format=[MeasureRSS2] (ant of course DynamicVariables=1). Will it work in that way?
What should I add to every meter (or by meter styles) to get it to work with all?
Skin update is set to 10 minutes, RSS is updated then, maybe run this script in the same time interval..
Feel so stupid..
BTW: There is skin which i'm trying implement it in.
Do i need
Code: Select all
[TestMeasure2]
Measure=TIME
Format=#String2#
It's measure output so it has to be Format=[MeasureRSS2] (ant of course DynamicVariables=1). Will it work in that way?
What should I add to every meter (or by meter styles) to get it to work with all?
Skin update is set to 10 minutes, RSS is updated then, maybe run this script in the same time interval..
Feel so stupid..
BTW: There is skin which i'm trying implement it in.
"Never argue with an idiot, he will drag you down to his level and beat you with experience."
my deviantART | Alternative Rainmeter tray icons
my deviantART | Alternative Rainmeter tray icons
-
- Moderator
- Posts: 1931
- Joined: January 29th, 2010, 1:43 am
- Location: Willmar, MN
Re: Show tooltip only if text clipped?
What you are asking about is simply a placeholder for the actual measure that you are using.
GitHub | DeviantArt | Tumblr
This is the song that never ends. It just goes on and on my friends. Some people started singing it not knowing what it was, and they'll continue singing it forever just because . . .
This is the song that never ends. It just goes on and on my friends. Some people started singing it not knowing what it was, and they'll continue singing it forever just because . . .
-
- Posts: 291
- Joined: July 25th, 2011, 9:53 am
- Location: Lublin, Poland
Re: Show tooltip only if text clipped?
Tell me like for idiot.. Where should I put what? Exacly code..
Maybe I'll understand finally then..
Maybe I'll understand finally then..
"Never argue with an idiot, he will drag you down to his level and beat you with experience."
my deviantART | Alternative Rainmeter tray icons
my deviantART | Alternative Rainmeter tray icons
-
- Moderator
- Posts: 1931
- Joined: January 29th, 2010, 1:43 am
- Location: Willmar, MN
Re: Show tooltip only if text clipped?
You save the lua code using notepad as Lua.lua, being sure to change the file type to "all files" and removing the .txt extension. Put it in the same folder as your skin.
In you skin add the following Measure. The MeterLenght line gives the script the name of a String Meter that we will use to determine the width of the text.
Now define the meter that we specified in the script measure.
We place it in the extreme negative coordinate region just so that it's not part of the skin that is shown.
Now we are going to set up a string meter to use out new script with.
When you mouseover the meter the script will fire, pulling the MeasureName from the meter itself. It will use the 'SpareMeter' that we defined to see how long the text is in pixels, and determine if the ToolTip is necessary.
In you skin add the following Measure. The MeterLenght line gives the script the name of a String Meter that we will use to determine the width of the text.
Code: Select all
[Lua]
Measure=Script
ScriptFile=Lua.lua
MeterLength=SpareMeter
Code: Select all
[SpareMeter]
Meter=String
X=-3000
Y=-1000
UpdateDivider=-1
Now we are going to set up a string meter to use out new script with.
Code: Select all
[SomeText]
Meter=String
MeasureName=SomeMeasure
H=10
W=100
ToolTipText=%1
MouseOverAction=!CommandMeasure Lua ToolTip('#CURRENTSECTION#')
GitHub | DeviantArt | Tumblr
This is the song that never ends. It just goes on and on my friends. Some people started singing it not knowing what it was, and they'll continue singing it forever just because . . .
This is the song that never ends. It just goes on and on my friends. Some people started singing it not knowing what it was, and they'll continue singing it forever just because . . .
-
- Posts: 3
- Joined: June 16th, 2012, 12:22 pm
Re: Show tooltip only if text clipped?
In this line, rainmeter 2.3.1 r1510 64-bit, return error: Script:Lua.lua:29:function arguments expected near '>='smurfier wrote: SKIN:Bang('!SetOption',MeterName,'ToolTipHidden',LengthHandle:GetW >= MeterHandle:GetW and 0 or 1)
Change to:
Code: Select all
SKIN:Bang('!SetOption',MeterName,'ToolTipHidden',LengthHandle:GetW() >= MeterHandle:GetW() and 0 or 1)