#!/bin/sh # MetaCard 2.4 stack # The following is not ASCII text, # so now would be a good time to q out of more exec mc $0 "$@" Managing Contextual Tooltips 2 Z/* Contextual tooltips Stack By Eric Chatonet 2/25/05 http://www.sosmartsoftware.com/ */ Managing Contextual Tooltips U Lucida Grande U Lucida Grande W Lucida Grande W Lucida Grande W Courier U Georgia U Georgia @U Lucida Grande cREVGeneral scriptChecksum Q dxw debugObjects bookmarks handlerList tempScript prevHandler scriptSelection char 51 to 50script U
/*
Contextual tooltips Stack
By Eric Chatonet
2/25/05
http://www.sosmartsoftware.com/
*/
P5constant kTab = " " -- HTML value for tab local lToolTipDelay ------------------------------------ on preOpenStack set the style of this stack to modeless set the loc of this stack to the screenLoc end preOpenStack ------------------------------------ on preOpenCard put the openstacks into tStacks sort tStacks international -- I think of French, Spanish and other users :-) repeat for each line tStack in tStacks if the fileName of stack tStack = empty then next repeat put " " & kTab & tStack & tab & the fileName of stack tStack & "
constant kTab = "	" -- HTML value for tab
local lToolTipDelay
------------------------------------
on preOpenStack
set the style of this stack to modeless
set the loc of this stack to the screenLoc
end preOpenStack
------------------------------------
on preOpenCard
put the openstacks into tStacks
sort tStacks international -- I think of French, Spanish and other users :-)
repeat for each line tStack in tStacks
if the fileName of stack tStack = empty then next repeat
put "<p> <img src=" & quote & "1006" & quote & ">" & kTab & tStack & tab & the fileName of stack tStack & "</p>" & cr after tList
-- 1006 is the ID of the checkmark image stored into this stack
end repeat
delete last char of tList
set the htmlText of fld "List" to tList
set the hilitedLine of fld "List" to 1
choose browse tool
-----
put the toolTipDelay into lToolTipDelay
SetTooltipDelay --
end preOpenCard
------------------------------------
on closeCArd
set the tooltipDelay to lToolTipDelay
end closeCArd
------------------------------------
on ToggleCheckmark pLine
local tCurStack,tHtmlText,tHtmlLine
-----
set the itemDel to tab
put item 2 of the hilitedText of fld "List" into tCurStack
-----
set the itemDel to "&"
put the htmlText of fld "List" into tHtmlText
put line pLine of tHtmlText into tHtmlLine
set the itemDel to "&"
-----
if "img src=" is in item 1 of tHtmlLine then put char 1 to 3 of item 1 of tHtmlLine into item 1 of line pLine of tHtmlText
else put " <img src=" & quote & "1006" & quote & ">" after item 1 of line pLine of tHtmlText
-----
set the htmlText of fld "List" to tHtmlText
-----
set the hilitedLine of fld "List" to lineOffset(tCurStack,fld "List")
end ToggleCheckmark
------------------------------------
on SetTooltipDelay
switch the menuHistory of btn "Delay"
case 1
set the tooltipDelay to 1 -- 0 means no tooltip
break
case 2
set the tooltipDelay to 100
break
case 3
set the tooltipDelay to 200
break
default
set the tooltipDelay to 500
end switch
end SetTooltipDelay
@ BlackCheckmark.png PNG IHDR pHYs gAMA |Q cHRM z% u0 ` : o_F xIDATxb` 17 R@L:̤/@,0@ 1I +x%@ Lħ HW ť $@PIV dĊK8 0 6 IENDB` cREVGeneral revUniqueID 1109347801497 Field i r cREVGeneral revUniqueID 1109350000228 List )y P-- Managing complex contextual tooltips with a mousemove handler ------------------------------------ on mouseUp if ClickedColumn("List") = 1 then -- see this function below -- put word 2 of the clickLine into tLineNo -- use clickLine to check vertical mouse position -- your stuff here ToggleCheckmark the hilitedLine of me -- C -- see this handler in the card script if you are intererested else -- we are in the right column -- your stuff here end if mouseMove -- -- sets the tooltip: see below end mouseUp ------------------------------------ on mouseMove if "ShowTips" is not among the lines the pendingMessages then send "ShowTips" to me in the toolTipDelay milliseconds -- we send a pending message -- delay is fixed by toolTipDelay function: see the docs about this function (500 milliseconds by default) -- here toolTipDelay value can be changed using the option menu end mouseMove ------------------------------------ function ClickedColumn pFldName -- field tabstops are used to check horizontal clickLoc position local tH,tVal,tTabsList ----- put item 1 of the clickLoc - the left of fld pFldName into tH put 0 into tVal repeat with i = the number of items of the tabStops of fld pFldName down to 1 put item i of the tabStops of fld pFldName - item i-1 of the tabStops of fld pFldName & comma before tTabsList end repeat delete last char of tTabsList repeat with i = 1 to the number of items of tTabsList add item i of tTabsList to tVal if tVal > tH then return i end repeat end ClickedColumn ------------------------------------ function MouseColumn pFldName -- field tabstops are used to check horizontal mouseLoc position local tH,tVal,tTabsList ----- put item 1 of the mouseLoc - the left of fld pFldName into tH put 0 into tVal repeat with i = the number of items of the tabStops of fld pFldName down to 1 put item i of the tabStops of fld pFldName - item i-1 of the tabStops of fld pFldName & comma before tTabsList end repeat delete last char of tTabsList repeat with i = 1 to the number of items of tTabsList add item i of tTabsList to tVal if tVal > tH then return i end repeat end MouseColumn ------------------------------------ on ShowTips local tLine,tTooltip,tAddUp ----- put word 2 of the mouseLine into tLine -- mouseline (see the docs) is the line the mouse is flying over -- use mouseline to check vertical mouse position ----- if MouseColumn("List") = 2 then -- see this function above -- then we are in the right column : use field tabstops to check horizontal mouse position set the itemDel to tab put item 3 of line tLine of me into tTooltip -- information is hidden from the user but it is in the field: that's another trick -- see my other "How to" stack about HTML lists for more details about hidden information if the tooltip of me <> tTooltip then set the toolTip of me to empty -- important set the toolTip of me to tTooltip end if else set the itemDel to tab if "img src=" is in the htmlText of line tLine of me then -- there is a checkmark in the mouseLine put "Uncheck" && quote & item 2 of line tLine of me & quote && "to..." into tTooltip else if line tLine of me <> empty then -- there is no checkmark in the mouseLine and it is not a blank line put "Check" && quote & item 2 of line tLine of me & quote && "to..." into tTooltip end if if the tooltip of me <> tTooltip then set the toolTip of me to empty -- important set the toolTip of me to tTooltip end if end if end ShowTips @ " i Choice 1
Choice 2
Choice 3
Choice 4
Choice 5
Choice 6
Choice 7<
Choice 1
Choice 2
Choice 3
Choice 4
Choice 5
Choice 6
Choice 7
Choice 1
Choice 2
Choice 3
Choice 4
Choice 5
Choice 6
Choice 7