It is currently April 27th, 2024, 2:16 pm

Show tooltip only if text clipped?

Report bugs with the Rainmeter application and suggest features.
User avatar
lysy1993lbn
Posts: 291
Joined: July 25th, 2011, 9:53 am
Location: Lublin, Poland

Show tooltip only if text clipped?

Post by lysy1993lbn »

Is it possible to enable tooltip only if some string is clipped by "Clipstring=1" setting?
Otherwise (if text fits in area) disable them?
"Never argue with an idiot, he will drag you down to his level and beat you with experience."
my deviantART | Alternative Rainmeter tray icons
User avatar
KreAch3R
Posts: 608
Joined: February 7th, 2011, 7:27 pm
Location: Thessaloniki, GR

Re: Show tooltip only if text clipped?

Post by KreAch3R »

You could emulate Clipstring through .lua (not perfectly), and then have the .lua script toggle the visibility of two meters, one with the Tooltip and one without, depending on string length.
Inactive, due to life changes. Send me a PM for any question.

Desktop DeviartArt
Image
User avatar
jsmorley
Developer
Posts: 22631
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Show tooltip only if text clipped?

Post by jsmorley »

lysy1993lbn wrote:Is it possible to enable tooltip only if some string is clipped by "Clipstring=1" setting?
Otherwise (if text fits in area) disable them?
Although in reality the answer is pretty much no. There is no way in Rainmeter itself to know the "length" of a string, and although in Lua you certainly could know the length of the string in characters, there is no reliable way to know based on that when Rainmeter is going to truncate the string due to ClipString=1. It is wildly variable depending on the font, the font size and the settings of the W= and H= options on the meter(s).

The only thing that would work reasonably well is to have Lua completely control the output. By that I mean don't put ClipString=1 on the meter at all, but rather just have the Lua get the value that is going to be used as the output of the meter by reading the value of the measure driving it. Then decide on a number of characters you want on the meter, (you will need to figure this out based on the font and size and width you are using in the skin) get the length in characters of the string from the measure, then create a new string in Lua that is the first xx chars of the original string -3 and concatenated with "...". Then use !SetOption to set the Text option of the meter with the new string, and !SetOption to set the ToolTipText value of the meter either with the full original string or "" to disable it.
User avatar
jsmorley
Developer
Posts: 22631
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Show tooltip only if text clipped?

Post by jsmorley »

P.S. That is more or less exactly what KreAch3R was getting at...
User avatar
KreAch3R
Posts: 608
Joined: February 7th, 2011, 7:27 pm
Location: Thessaloniki, GR

Re: Show tooltip only if text clipped?

Post by KreAch3R »

Exactly. That's how I 've done it in my latest RSS reader. :) Given the difficulty, though, and the imperfect results, that's why I said "could". :p
Inactive, due to life changes. Send me a PM for any question.

Desktop DeviartArt
Image
User avatar
~Faradey~
Posts: 366
Joined: November 12th, 2009, 4:47 pm
Location: Ukraine

Re: Show tooltip only if text clipped?

Post by ~Faradey~ »

i think i know how to do it
i need to do some testings...just wait ;)
User avatar
lysy1993lbn
Posts: 291
Joined: July 25th, 2011, 9:53 am
Location: Lublin, Poland

Re: Show tooltip only if text clipped?

Post by lysy1993lbn »

I wanted to do this in my RSS reader too, but I'll give up on this..
I'm really dumb at lua scripts, and want keep my skins simple as possible anyway so..

Thanks for trying help anyway.. I appreciate it :)
"Never argue with an idiot, he will drag you down to his level and beat you with experience."
my deviantART | Alternative Rainmeter tray icons
User avatar
lysy1993lbn
Posts: 291
Joined: July 25th, 2011, 9:53 am
Location: Lublin, Poland

Re: Show tooltip only if text clipped?

Post by lysy1993lbn »

MAybe is at least possible to delay tooltip showing?

Becouse now.. easiest way is thow on video: http://youtu.be/pSWOOJ4WaHM
"Never argue with an idiot, he will drag you down to his level and beat you with experience."
my deviantART | Alternative Rainmeter tray icons
User avatar
~Faradey~
Posts: 366
Joined: November 12th, 2009, 4:47 pm
Location: Ukraine

Re: Show tooltip only if text clipped?

Post by ~Faradey~ »

Here, try this example, is that what you need?
i think you will be able to fit it into your code ;)
(just change String variable and refresh the skin to see)

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1

[Variables]
String="Hello i am a very very very long string"

[CHCD]
Measure=Script
ScriptFile="#CURRENTPATH#ch_mcd.lua"
UpdateDivider=1
Meter1=MeterToGetStringWidth
Meter2=TestMeter

[TestMeasure]
Measure=TIME
Format=#String#

[TestMeter]
Meter=String
MeasureName=TestMeasure
X=0
Y=0
W=100
H=14
ToolTipText="#String#"
ToolTipHidden=1
FontColor=255,255,255
SolidColor=0,0,0,1
Hidden=0
;Text="#String#"
ClipString=1

[MeterToGetStringWidth]
Meter=String
MeasureName=TestMeasure
X=-3000
Y=-1000
Hidden=0
;Text="#String#"
Lua Script. Save it with name ch mcd.lua (or pick another but don't forget to edit it in skin file) and place it in skin's directory.

Code: Select all

PROPERTIES =
{

}

function Initialize()
 
end -->Initialize

function Update()
sMeterSetting1,sMeterSetting2 = SELF:GetOption('Meter1'),SELF:GetOption('Meter2')
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 TestMeter ToolTipHidden 0")
	SKIN:Bang("!UpdateMeter TestMeter")
	SKIN:Bang("!Redraw")
else 
	SKIN:Bang("!SetOption TestMeter ToolTipHidden 1")
	SKIN:Bang("!UpdateMeter TestMeter")
	SKIN:Bang("!Redraw")
end	
end -->Update
Notice! This example works if you don't use Text="%1" in your meters!...otherwise it will not work and will need to be rewritten
User avatar
lysy1993lbn
Posts: 291
Joined: July 25th, 2011, 9:53 am
Location: Lublin, Poland

Re: Show tooltip only if text clipped?

Post by lysy1993lbn »

~Faradey~ wrote:Notice! This example works if you don't use Text="%1" in your meters!...otherwise it will not work and will need to be rewritten
Unfortunetly Text=%1 is exacly what I use :(
"Never argue with an idiot, he will drag you down to his level and beat you with experience."
my deviantART | Alternative Rainmeter tray icons