Skip to content

Commit

Permalink
Another attempt at using RemovalConditions->{"MouseExit"} for copy to…
Browse files Browse the repository at this point in the history
…oltip.

Also, reduce the horizontal size of the tooltip by 50 points.  It was built
for a wider purpose which is unnecessary here, and the wider appearance was
being horizontally cropped in the NA interface.
  • Loading branch information
jfultz committed Dec 2, 2024
1 parent f459e04 commit fa5885e
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 11 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
48 changes: 37 additions & 11 deletions Source/Chatbook/Formatting.wl
Original file line number Diff line number Diff line change
Expand Up @@ -899,17 +899,43 @@ insertCodeInUserNotebook // endDefinition;
attachCopiedTooltip // beginDefinition;

attachCopiedTooltip[ ] :=
With[
{
cellObj = AttachCell[
EvaluationBox[ ],
Cell[ BoxData[ TemplateBox[ { "Copied" }, "ClickToCopyTooltip" ] ] ],
{ Center, Bottom }, Offset[ { 0, 5 }, Automatic ], { Center, Top },
RemovalConditions -> { "MouseClickOutside" }
]
},
SessionSubmit @ ScheduledTask[ NotebookDelete @ cellObj, { 1.2 } ]
];
AttachCell[
EvaluationBox[ ],
Cell[ BoxData[
PaneBox[
PanelBox[
GridBox[{{PaneBox[
DynamicBox[
StyleBox[
FEPrivate`ImportImage[
FrontEnd`FileName[{"Typeset", "ClickToCopy"}, "Checkmark.png"]],
Magnification -> 0.5`]],
BaselinePosition -> Scaled[0.1`] -> Baseline],
DynamicBox[
ToBoxes[FEPrivate`FrontEndResource["FEStrings",
"clicktocopyDoneTooltip"], StandardForm]]}},
GridBoxAlignment -> {"Columns" -> {{Left}}, "Rows" -> {{Baseline}}},
GridBoxItemSize -> {"Columns" -> {{Automatic}},
"Rows" -> {{Automatic}}},
GridBoxSpacings -> {"Columns" -> {{0.3`}}, "Rows" -> {{0}}}],
Alignment -> Center,
Appearance -> {"Default" ->
FrontEnd`FileName[{"Chatbook"}, "CopyTooltip.9.png"]}, ImageSize -> {100, Automatic},
FrameMargins -> {{0, 0}, {0, 0}},
BaseStyle -> {LineBreakWithin -> Automatic,
LinebreakAdjustments -> {1.`, 10, 1, 0, 1}, LineIndent -> 0,
Hyphenation -> False,
HyphenationOptions -> {"HyphenationCharacter" -> "\[Null]"},
FontFamily -> "Source Sans Pro", FontSize -> 12,
FontColor -> GrayLevel[0.5]}],
Alignment -> { Center, Bottom },
FrameMargins -> 0,
ImageSize -> { All, 60 }
]
] ],
{ Center, Bottom }, Offset[ { 0, -7 }, Automatic ], { Center, Center },
RemovalConditions -> { "MouseExit" }
];

attachCopiedTooltip // endDefinition;

Expand Down

0 comments on commit fa5885e

Please sign in to comment.